ld capping section/segment address at 1<<32
Roland McGrath
mcgrathr@google.com
Fri Nov 11 00:16:00 GMT 2011
I've just filed http://sourceware.org/bugzilla/show_bug.cgi?id=13400
for this.
I'm posting here too in hopes of slightly quicker response and because I'm
interested in any discussion. Is anyone aware of a problem like this already?
What's especially notable is that the truncated section/segment size makes
it so the section/segment ends at exactly 1<<32. That makes it seem
suspiciously like there is some 32-bit arithmetic going on somewhere.
Thanks,
Roland
$ cat toobig.s
.text
.globl _start
_start: hlt
$ cat toobig.x
ENTRY(_start)
PHDRS {
text PT_LOAD FILEHDR PHDRS;
data PT_LOAD;
reserve PT_LOAD FLAGS(0);
note PT_NOTE;
stack PT_GNU_STACK FLAGS(6);
}
RESERVE_TOP = 0x1500000000;
SECTIONS {
. = 0x10000 + SIZEOF_HEADERS;
.note.gnu.build-id : {
*(.note.gnu.build-id)
} :text :note
.text : {
*(.text*)
} :text
.rodata : {
*(.rodata*)
*(.eh_frame*)
}
etext = .;
. = (ALIGN(CONSTANT(MAXPAGESIZE)) -
((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)));
. = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE));
.data : {
*(.data*)
} :data
.bss : {
*(.bss*)
}
. = ALIGN(CONSTANT(COMMONPAGESIZE));
RESERVE_START = .;
.reserve : {
. = RESERVE_TOP - RESERVE_START;
} :reserve
}
$ ./ld/ld-new -m elf_x86_64 --build-id -static -z
max-page-size=0x1000 --script=toobig.x -o toobig toobig.o
$ readelf -lSs toobig
There are 7 section headers, starting at offset 0x1c0:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .note.gnu.build-i NOTE 0000000000010158 00000158
0000000000000024 0000000000000000 A 0 0 4
[ 2] .text PROGBITS 000000000001017c 0000017c
0000000000000001 0000000000000000 AX 0 0 4
[ 3] .reserve NOBITS 0000000000012000 00001000
00000000fffee000 0000000000000000 WA 0 0 1
[ 4] .shstrtab STRTAB 0000000000000000 0000017d
000000000000003d 0000000000000000 0 0 1
[ 5] .symtab SYMTAB 0000000000000000 00000380
00000000000000c0 0000000000000018 6 4 8
[ 6] .strtab STRTAB 0000000000000000 00000440
0000000000000028 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Elf file type is EXEC (Executable file)
Entry point 0x1017c
There are 5 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000010000 0x0000000000010000
0x000000000000017d 0x000000000000017d R E 1000
LOAD 0x000000000000017d 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 1000
LOAD 0x0000000000001000 0x0000000000012000 0x0000000000012000
0x0000000000000000 0x00000000fffee000 1000
NOTE 0x0000000000000158 0x0000000000010158 0x0000000000010158
0x0000000000000024 0x0000000000000024 R 4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 8
Section to Segment mapping:
Segment Sections...
00 .note.gnu.build-id .text
01
02 .reserve
03 .note.gnu.build-id
04
Symbol table '.symtab' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000010158 0 SECTION LOCAL DEFAULT 1
2: 000000000001017c 0 SECTION LOCAL DEFAULT 2
3: 0000000000012000 0 SECTION LOCAL DEFAULT 3
4: 0000001500000000 0 NOTYPE GLOBAL DEFAULT ABS RESERVE_TOP
5: 000000000001017d 0 NOTYPE GLOBAL DEFAULT ABS etext
6: 000000000001017c 0 NOTYPE GLOBAL DEFAULT 2 _start
7: 0000000000012000 0 NOTYPE GLOBAL DEFAULT ABS RESERVE_START
$
More information about the Binutils
mailing list