bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/20092] New: Wrong relaxation with R_X86_64_GOTPCREL


From: ubizjak at gmail dot com
Subject: [Bug ld/20092] New: Wrong relaxation with R_X86_64_GOTPCREL
Date: Fri, 13 May 2016 17:13:43 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=20092

            Bug ID: 20092
           Summary: Wrong relaxation with R_X86_64_GOTPCREL
           Product: binutils
           Version: 2.25
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Soon to be attached object files, compiled from GCC testsuite
(gcc/testsuite/gcc.target/i386):

$ gcc -mcmodel=medium -fpic -fdata-sections -c pr61599-1.c

and

$ gcc -mcmodel=medium -fpic -fdata-sections -c pr61599-2.c

result in following linker error when BFD linker is used:

$ gcc -fuse-ld=bfd pr61599-1.o pr61599-2.o
pr61599-2.o: In function `bar':
pr61599-2.c:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against
symbol `a' defined in LARGE_COMMON section in pr61599-1.o
collect2: error: ld returned 1 exit status

while they succeed with GOLD linker:

$ gcc -fuse-ld=gold pr61599-1.o pr61599-2.o
$ ./a.out

Please note that there is no R_X86_64_PC32 relocation in object files, so it
looks like wrong relaxation to me:

$ objdump -dr pr61599-1.o

pr61599-1.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <main>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 8d 05 00 00 00 00    lea    0x0(%rip),%rax        # b <main+0xb>
                        7: R_X86_64_GOTPC32     _GLOBAL_OFFSET_TABLE_-0x4
   b:   b8 00 00 00 00          mov    $0x0,%eax
  10:   e8 00 00 00 00          callq  15 <main+0x15>
                        11: R_X86_64_PLT32      bar-0x4
  15:   89 c2                   mov    %eax,%edx
  17:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 1e <main+0x1e>
                        1a: R_X86_64_GOTPCREL   c-0x4
  1e:   0f b6 80 e1 00 00 00    movzbl 0xe1(%rax),%eax
  25:   0f be c0                movsbl %al,%eax
  28:   01 d0                   add    %edx,%eax
  2a:   5d                      pop    %rbp
  2b:   c3                      retq   

$ objdump -dr pr61599-2.o

pr61599-2.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 8d 05 00 00 00 00    lea    0x0(%rip),%rax        # b <bar+0xb>
                        7: R_X86_64_GOTPC32     _GLOBAL_OFFSET_TABLE_-0x4
   b:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 12 <bar+0x12>
                        e: R_X86_64_GOTPCREL    a-0x4
  12:   0f b6 40 02             movzbl 0x2(%rax),%eax
  16:   0f be d0                movsbl %al,%edx
  19:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 20 <bar+0x20>
                        1c: R_X86_64_GOTPCREL   b-0x4
  20:   0f b6 40 10             movzbl 0x10(%rax),%eax
  24:   0f be c0                movsbl %al,%eax
  27:   01 c2                   add    %eax,%edx
  29:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 30 <bar+0x30>
                        2c: R_X86_64_GOTPCREL   c-0x4
  30:   0f b6 80 00 01 00 00    movzbl 0x100(%rax),%eax
  37:   0f be c0                movsbl %al,%eax
  3a:   01 d0                   add    %edx,%eax
  3c:   5d                      pop    %rbp
  3d:   c3                      retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]