$ gold --version GNU gold (GNU Binutils for Debian 2.25.90.20151209) 1.11 Copyright (C) 2015 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. $ cat > test.c <<EOF void foo() {} EOF $ gcc -shared -o test.so test.c -fuse-ld=gold -nostartfiles $ readelf -Sl test.so There are 16 section headers, starting at offset 0x598: 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 00000000000001c8 000001c8 0000000000000024 0000000000000000 A 0 0 4 [ 2] .dynsym DYNSYM 00000000000001f0 000001f0 0000000000000078 0000000000000018 A 3 1 8 [ 3] .dynstr STRTAB 0000000000000268 00000268 0000000000000027 0000000000000000 A 0 0 1 [ 4] .gnu.hash GNU_HASH 0000000000000290 00000290 0000000000000034 0000000000000000 A 2 0 8 [ 5] .text PROGBITS 00000000000002c4 000002c4 0000000000000007 0000000000000000 AX 0 0 1 [ 6] .eh_frame PROGBITS 00000000000002d0 000002d0 0000000000000038 0000000000000000 A 0 0 8 [ 7] .eh_frame_hdr PROGBITS 0000000000000308 00000308 0000000000000014 0000000000000000 A 0 0 4 [ 8] .dynamic DYNAMIC 0000000000001320 00000320 00000000000000c0 0000000000000010 WA 3 0 8 [ 9] .data PROGBITS 00000000000013e0 000003e0 0000000000000000 0000000000000000 WA 0 0 1 [10] .bss NOBITS 00000000000013e0 000003e0 0000000000000000 0000000000000000 WA 0 0 1 [11] .comment PROGBITS 0000000000000000 000003e0 0000000000000027 0000000000000001 MS 0 0 1 [12] .note.gnu.gold-ve NOTE 0000000000000000 00000408 000000000000001c 0000000000000000 0 0 4 [13] .symtab SYMTAB 0000000000000000 00000428 00000000000000a8 0000000000000018 14 3 8 [14] .strtab STRTAB 0000000000000000 000004d0 000000000000002d 0000000000000000 0 0 1 [15] .shstrtab STRTAB 0000000000000000 000004fd 000000000000009a 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is DYN (Shared object file) Entry point 0x0 There are 7 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040 0x0000000000000188 0x0000000000000188 R 8 LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x000000000000031c 0x000000000000031c R E 1000 LOAD 0x000000000000031c 0x000000000000131c 0x000000000000131c 0x00000000000000c4 0x00000000000000c4 RW 1000 DYNAMIC 0x0000000000000320 0x0000000000001320 0x0000000000001320 0x00000000000000c0 0x00000000000000c0 RW 8 NOTE 0x00000000000001c8 0x00000000000001c8 0x00000000000001c8 0x0000000000000024 0x0000000000000024 R 4 GNU_EH_FRAME 0x0000000000000308 0x0000000000000308 0x0000000000000308 0x0000000000000014 0x0000000000000014 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0 Section to Segment mapping: Segment Sections... 00 01 .note.gnu.build-id .dynsym .dynstr .gnu.hash .text .eh_frame .eh_frame_hdr 02 .dynamic 03 .dynamic 04 .note.gnu.build-id 05 .eh_frame_hdr 06 The relevant parts are that the second PT_LOAD starts at 0x31c and contains .dynamic, which starts at 0x320. It fortunately compensates on the size to end at the right address.
Bisected: a5cd8f05ca759fdb9b27fc98a08edb5f85369ad9 is the first bad commit commit a5cd8f05ca759fdb9b27fc98a08edb5f85369ad9 Author: Cary Coutant <ccoutant@google.com> Date: Fri Jan 9 15:55:50 2015 -0800 Don't align start of segment unless alignment is larger than page size. This fixes an issue where a page-aligned data section, combined with -z relro, could lead to a gap between text and data segments larger than a page, and we would fail to overlap the segments in the file. gold/ * layout.cc (Layout::set_segment_offsets): Don't align start of segment unless alignment is larger than page size. :040000 040000 a0187d8ed6745a9d727f8b342e79a9c57216a93e 93e6a9db741fc3ec9bd7cb4f22199bd4e9af672c M gold