[Bug 970] #pragma visibility hidden in MdePkg/Include/X64/ProcessorBind.h is misconceived #pragma
bugzilla-daemon at bugzilla.tianocore.org...
--- Comment #7 from zenith432(a)users.sourceforge.net ---
As you may be aware, the Tianocore crowd are obsessed with binary size, and- I've examined the generated code - using -fpie eliminates nearly 100% of
GOTPCREL emitted by GCC, and it's a coincidence that some are left behind - and
that the ones left behind are not transformable by ld.
- It is also a coincidence that -fvisiblity=hidden eliminates the remaining
cases. There are code constructs not used in EDK2 that still emit GOTPCREL and
you haven't run into. I mentioned this in my first post. Take this example.
#define SIZE_OF_THUNK 9
extern void thunkArea(void);
extern long const offsetOfThunkTable;
unsigned long compute_thunk_address(long thunkIndexInTable)
return (unsigned long) thunkArea + offsetOfThunkTable * SIZE_OF_THUNK +
thunkIndexInTable * SIZE_OF_THUNK;
gcc -Os -fpie -fvisibility=hidden -c -o a.o a.c
objdump -dr a.o
0: 48 6b 05 00 00 00 00 imul $0x9,0x0(%rip),%rax # 8
3: R_X86_64_PC32 offsetOfThunkTable-0x5
8: 48 8d 3c ff lea (%rdi,%rdi,8),%rdi
c: 48 03 05 00 00 00 00 add 0x0(%rip),%rax # 13
f: R_X86_64_REX_GOTPCRELX thunkArea-0x4
13: 48 01 f8 add %rdi,%rax
16: c3 retq
With -fpie -fvisibility=hidden emitted GOTPCREL relocation with add instruction
that can't be eliminated by ld. GCC 8.1.1 as before.
I made the example a little more elaborate than needs to be, to make GCC emit
an "add" instruction. A simpler pointer computation sometimes emits a "mov"
instruction (which can be transformed by ld), and some other forms of pointer
arithmetic drop the GOTPCREL altogether.
You are receiving this mail because:
You are on the CC list for the bug.