[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/21453] New: Safe ICF doesn't work with -fno-plt
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug gold/21453] New: Safe ICF doesn't work with -fno-plt |
Date: |
Tue, 02 May 2017 18:13:08 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=21453
Bug ID: 21453
Summary: Safe ICF doesn't work with -fno-plt
Product: binutils
Version: 2.29 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: hjl.tools at gmail dot com
CC: ian at airs dot com, rahulchaudhry at chromium dot org,
tmsriram at google dot com
Target Milestone: ---
Target: i386, x86_64
When fno-plt is used, GOT relocation will be used to call external functions:
00000000 <main>:
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 83 ec 10 sub $0x10,%esp
12: e8 fc ff ff ff call 13 <main+0x13> 13: R_386_PC32
__x86.get_pc_thunk.bx
17: 81 c3 02 00 00 00 add $0x2,%ebx 19: R_386_GOTPC
_GLOBAL_OFFSET_TABLE_
1d: 8b 83 00 00 00 00 mov 0x0(%ebx),%eax 1f: R_386_GOT32X
foo_glob
23: 89 45 f4 mov %eax,-0xc(%ebp)
26: ff 93 00 00 00 00 call *0x0(%ebx) 28: R_386_GOT32X
bar_glob
2c: ff 93 00 00 00 00 call *0x0(%ebx) 2e: R_386_GOT32X
foo_normal
32: ff 93 00 00 00 00 call *0x0(%ebx) 34: R_386_GOT32X
foo_default
38: b8 00 00 00 00 mov $0x0,%eax
3d: 83 c4 10 add $0x10,%esp
40: 59 pop %ecx
41: 5b pop %ebx
42: 5d pop %ebp
43: 8d 61 fc lea -0x4(%ecx),%esp
46: c3 ret
Gold needs to check opcode for branches to enable safe ICF:
address@hidden gold-1]$ cat x.c
extern int foo_normal(void);
extern int foo_default(void);
extern int foo_glob(void);
extern int bar_glob(void);
int main()
{
int (*p)() = foo_glob;
(void)p;
bar_glob ();
foo_normal();
foo_default();
return 0;
}
address@hidden gold-1]$ cat y.c
int
foo_normal(void)
{
return 1;
}
int
foo_default(void)
{
return 1;
}
int foo_glob(void)
{
return 2;
}
int bar_glob(void)
{
return 2;
}
address@hidden gold-1]$ make x
/export/build/gnu/gcc-7/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-7/build-x86_64-linux/gcc/ -m32 -c -fPIE
-ffunction-sections -fno-plt -o x.o x.c
/export/build/gnu/gcc-7/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-7/build-x86_64-linux/gcc/ -m32 -c -fPIE
-ffunction-sections -fno-plt -o y.o y.c
./ld -pie --icf=safe -Map x.map -m elf_i386 -o x x.o y.o
address@hidden gold-1]$ cat x.map
Discarded input sections
.group 0x00000000 0x8 x.o
.note.GNU-stack
0x00000000 0x0 x.o
.group 0x00000000 0x8 y.o
.note.GNU-stack
0x00000000 0x0 y.o
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gold/21453] New: Safe ICF doesn't work with -fno-plt,
hjl.tools at gmail dot com <=