bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/26936] New: [ld, PIE] ld drops relocation for .text.__x86.get_pc


From: vries at gcc dot gnu.org
Subject: [Bug ld/26936] New: [ld, PIE] ld drops relocation for .text.__x86.get_pc_thunk.bx
Date: Tue, 24 Nov 2020 09:22:51 +0000

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

            Bug ID: 26936
           Summary: [ld, PIE] ld drops relocation for
                    .text.__x86.get_pc_thunk.bx
           Product: binutils
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ This is the ld variant of gdb PR26935. ]

Consider gcc testsuite test-case src/gcc/testsuite/gcc.dg/split-1.c.

When specifying -fsplit-stack, morestack.o is linked in, originating from
morestack.S in libgcc.

When specifying -m32 in combination with -fsplit-stack, morestack.o also
contains a function __x86.get_pc_thunk.bx, in section
.text.__x86.get_pc_thunk.bx.

So, when compiling like this:
...
$ gcc -g -fsplit-stack src/gcc/testsuite/gcc.dg/split-1.c -m32
...
we get in .debug_lines:
...
CU: libgcc/config/i386/morestack.S:
File name    Line number   Starting address        View    Stmt
morestack.S  109           0x8048a1e               x
morestack.S  113           0x8048a1f               x
  ...
morestack.S  832           0x8048b80               x
morestack.S  838           0x8048b85               x
morestack.S    -           0x8048b86

morestack.S  636           0x8048880               x
morestack.S  637           0x8048883               x
morestack.S    -           0x8048884
...
corresponding to:
...
08048a1e <__morestack_non_split>:
 8048a1e:       50                      push   %eax
...
and:
...
08048880 <__x86.get_pc_thunk.bx>:
 8048880:       8b 1c 24                mov    (%esp),%ebx
...

Now, we compile in addition with -pie -fPIE, and get instead in .debug_lines:
...
CU: libgcc/config/i386/morestack.S:
File name    Line number       Starting address    View    Stmt
morestack.S  109               0xb8b               x
morestack.S  113               0xb8c               x
   ...
morestack.S  838               0xcf2               x
morestack.S    -               0xcf3

morestack.S  636                   0               x
morestack.S  637                 0x3               x
morestack.S    -                 0x4
...
which matches with:
...
00000b8b <__morestack_non_split>:
     b8b:       50                      push   %eax
...
but not with:
...
00000b87 <__x86.get_pc_thunk.ax>:
     b87:       8b 04 24                mov    (%esp),%eax
...

Looking at the relocations for .debug_line in morestack.o, we have:
...
Relocation section '.rel.debug_line' at offset 0x8f4 contains 2 entries:
 Offset     Info    Type                Sym. Value  Symbol's Name
0000004e  00000101 R_386_32               00000000   .text
000000de  00000501 R_386_32               00000000  
.text.__x86.get_pc_thunk.bx
...
matching with .debug_lines here:
...
 Line Number Statements:
  [0x0000004b]  Extended opcode 2: set Address to 0x0
...
and:
...
  [0x000000db]  Extended opcode 2: set Address to 0x0
...

So, it looks like ld drops the second relocation in PIE mode.

-- 
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]