string constants in -fpie mode?

Segher Boessenkool segher@kernel.crashing.org
Sun Oct 30 03:46:00 GMT 2016


On Sat, Oct 29, 2016 at 04:01:51PM -0600, Tycho Andersen wrote:
> $ gcc -c -fpie -Wa,--noexecstack -fno-jump-tables -nostdlib tester.c -o tester.o
> $ ld -r tester.o -o tester.bin

Are you sure you want -r?

> So now I'm confused. .rodata is clearly my string (using a cheap hack by doing
> objdump -D to display it), but the code at 0x4 in .text has me confused,
> 
>    4: 48 8d 05 00 00 00 00  lea    rax,[rip+0x0]        # b <main+0xb>

You should always use the -r flag to objdump when disassembling object
files.


Segher



More information about the Gcc-help mailing list