What is R_X86_64_PC32?

James R. Van Artsdalen james at jrv.org
Thu Jan 27 11:27:06 PST 2005

Steve Kargl wrote:

>This simple fortran program:
>       program kk
>       implicit none
>       integer N
>       parameter (N=32768)
>       real input(N,N)
>       input(1,1) = 1.e0
>       end program kk
>when compiled by either the system's f77 command or gfortran,
>generates the following error:
>troutmask:kargl[217] f77 -o df df.f
>/usr/lib/crt1.o(.text+0x15): In function `_start':
>: relocation truncated to fit: R_X86_64_PC32 environ
>Is this an indication that the stack isn't large enough?
I don't think this is anything you're doing.

The error is actually a relocation being applied to the startup code in 

/* The entry function. */
_start(char **ap, void (*cleanup)(void))
        int argc;
        char **argv;
        char **env;
        const char *s;

        argc = *(long *)(void *)ap;
        argv = ap + 1;
        env = ap + 2 + argc;

I think the linker is getting the error trying to fixup the write to env 

0000000000000000 <_start>:
   0:   41 54                   push   %r12
   2:   55                      push   %rbp
   3:   53                      push   %rbx
   4:   8b 2f                   mov    (%rdi),%ebp
   6:   4c 8d 67 08             lea    0x8(%rdi),%r12
   a:   48 63 dd                movslq %ebp,%rbx
   d:   48 8d 5c df 10          lea    0x10(%rdi,%rbx,8),%rbx
  12:   48 89 1d 00 00 00 00    mov    %rbx,0(%rip)        # 19 

I *think* that last line is the write to env?  In that case there's only 
room for a 32-bit offset between the address of this code and that of env.

Peter, Dave: do we require that statically allocated data be within 2 GB 
of any code that might reference it by name?

Even if that's true it's not obvious to me why your test program isn't 
meeting such a requirement?

More information about the freebsd-amd64 mailing list