https://sourceware.org/bugzilla/show_bug.cgi?id=18201
Bug ID: 18201 Summary: Incorrect ELF generated when .text is below 0x200000 Product: binutils Version: 2.24 Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: bijuabrahamp at gmail dot com OS: Ubuntu 14.04, Fedora 21 ARCH : x86_64 Perform steps below to generate the incorrect ELF. $ cat test.c int main() { int x = 3; /* do something */ asm volatile("mov $60,%rax; mov $0,%rbx; syscall"); } $ cat mylinker.lds SECTIONS { . = 0x100000; .text : { *(.text) } . = 0x8000000; .data : { *(.data) } .bss : { *(.bss) } } $ gcc -c test.c $ ld -T mylinker.lds test.o -o test $ readelf -l test Elf file type is EXEC (Executable file) Entry point 0x100000 There are 2 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000100060 0x0000000000100060 R E 200000 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 10 Expected output : LOAD 0x0000000000100000 0x0000000000100000 0x0000000000000000 0x0000000000000060 0x0000000000000060 R E 200000 $ ./test Killed (Address 0 cannot be used by unprevileged users because of Linux kernel's mmap_min_addr) Manually fixing up the ELF file using hex editor or some utilty resolves the issue. $ git clone https://github.com/bjxt/elf_fixup $ cd elf_fixup $ ./fixelf -e test -o 0x100000 -f 0x60 -v 0x100000 -m 0x60 $ ./test Program completes successfully. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils