bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/23854] 16-bit GOT access is incorrectly optimized


From: hjl.tools at gmail dot com
Subject: [Bug ld/23854] 16-bit GOT access is incorrectly optimized
Date: Mon, 05 Nov 2018 07:55:25 +0000

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |i386,x86-64
             Status|WAITING                     |NEW
            Version|2.30                        |2.32 (HEAD)
            Summary|-no-pie -export-dynamic     |16-bit GOT access is
                   |corrupts binary             |incorrectly optimized

--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
address@hidden pr23854]$ cat x.c
extern void foo (void);

short
foo_p (void)
{
  return 0x400 - (int) &foo;
}
address@hidden pr23854]$ cat foo.c
extern short foo_p (void);

 __attribute__ ((visibility("hidden")))
void 
foo (void)
{
}

void
_start (void)
{
  foo_p ();
}
address@hidden pr23854]$ make
gcc -m32 -B./ -O2 -fPIE   -c -o x.o x.c
gcc -m32 -B./ -O2 -fPIE   -c -o foo.o foo.c
ld -melf_i386 -o x x.o foo.o
address@hidden pr23854]$ objdump -dw x.o

x.o:     file format elf32-i386


Disassembly of section .text:

00000000 <foo_p>:
   0:   e8 fc ff ff ff          call   1 <foo_p+0x1>
   5:   81 c2 02 00 00 00       add    $0x2,%edx
   b:   b8 00 04 00 00          mov    $0x400,%eax
  10:   66 2b 82 00 00 00 00    sub    0x0(%edx),%ax
  17:   c3                      ret    

Disassembly of section .text.__x86.get_pc_thunk.dx:

00000000 <__x86.get_pc_thunk.dx>:
   0:   8b 14 24                mov    (%esp),%edx
   3:   c3                      ret    
address@hidden pr23854]$ objdump -dw x

x:     file format elf32-i386


Disassembly of section .text:

08049000 <foo_p>:
 8049000:       e8 13 00 00 00          call   8049018 <__x86.get_pc_thunk.dx>
 8049005:       81 c2 fb 2f 00 00       add    $0x2ffb,%edx
 804900b:       b8 00 04 00 00          mov    $0x400,%eax
 8049010:       66 81 e8 20 90          sub    $0x9020,%ax
 8049015:       04 08                   add    $0x8,%al
 8049017:       c3                      ret    

08049018 <__x86.get_pc_thunk.dx>:
 8049018:       8b 14 24                mov    (%esp),%edx
 804901b:       c3                      ret    
 804901c:       66 90                   xchg   %ax,%ax
 804901e:       66 90                   xchg   %ax,%ax

08049020 <foo>:
 8049020:       c3                      ret    
 8049021:       8d b4 26 00 00 00 00    lea    0x0(%esi,%eiz,1),%esi
 8049028:       8d b4 26 00 00 00 00    lea    0x0(%esi,%eiz,1),%esi
 804902f:       90                      nop

08049030 <_start>:
 8049030:       53                      push   %ebx
 8049031:       e8 13 00 00 00          call   8049049 <__x86.get_pc_thunk.bx>
 8049036:       81 c3 ca 2f 00 00       add    $0x2fca,%ebx
 804903c:       83 ec 08                sub    $0x8,%esp
 804903f:       e8 bc ff ff ff          call   8049000 <foo_p>
 8049044:       83 c4 08                add    $0x8,%esp
 8049047:       5b                      pop    %ebx
 8049048:       c3                      ret    

08049049 <__x86.get_pc_thunk.bx>:
 8049049:       8b 1c 24                mov    (%esp),%ebx
 804904c:       c3                      ret    
address@hidden pr23854]$

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