This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: VMA section overlap warnings for overlays
- From: Andreas Schwab <schwab at redhat dot com>
- To: David Stubbs <stubbs at IceraSemi dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 15 Jul 2010 15:46:28 +0200
- Subject: Re: VMA section overlap warnings for overlays
- References: <4D60B0700D1DB54A8C0C6E9BE69163700E67DFD1@EXCHANGEVS.IceraSemi.local> <20100421082441.GG3510@bubble.grove.modra.org> <4D60B0700D1DB54A8C0C6E9BE69163700E7815C7@EXCHANGEVS.IceraSemi.local> <20100422011106.GI3510@bubble.grove.modra.org> <20100422015303.GK3510@bubble.grove.modra.org> <4D60B0700D1DB54A8C0C6E9BE69163700E7F2F15@EXCHANGEVS.IceraSemi.local> <20100424021750.GQ3510@bubble.grove.modra.org> <m37hkxxizs.fsf@hase.home> <20100715130955.GH31087@bubble.grove.modra.org>
Alan Modra <amodra@gmail.com> writes:
> On Thu, Jul 15, 2010 at 10:11:03AM +0200, Andreas Schwab wrote:
>> Alan Modra <amodra@gmail.com> writes:
>>
>> > @@ -5837,7 +5853,8 @@ copy_elf_program_header (bfd *ibfd, bfd
>> > section = section->next)
>> > {
>> > this_hdr = &(elf_section_data(section)->this_hdr);
>> > - if (ELF_IS_SECTION_IN_SEGMENT_FILE (this_hdr, segment))
>> > + if (this_hdr->sh_size != 0
>> > + && ELF_SECTION_IN_SEGMENT (this_hdr, segment))
>>
>> Why can't an empty section never be part of a segment?
>
> Good question. I didn't change anything with that patch.
> HJ's ELF_IS_SECTION_IN_SEGMENT_FILE included the sh_size check.
The problem is that it clobbers the file offset of such an empty section
during objcopy/strip.
$ binutils/readelf -WSl libfreebl3.so
There are 41 section headers, starting at offset 0xe25b8:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .note.gnu.build-id NOTE 0000000000000190 000190 000024 00 A 0 0 4
[ 2] .gnu.hash GNU_HASH 00000000000001b8 0001b8 000050 00 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000000208 000208 000798 18 A 4 3 8
[ 4] .dynstr STRTAB 00000000000009a0 0009a0 000336 00 A 0 0 1
[ 5] .gnu.version VERSYM 0000000000000cd6 000cd6 0000a2 02 A 3 0 2
[ 6] .gnu.version_d VERDEF 0000000000000d78 000d78 000054 00 A 4 3 8
[ 7] .gnu.version_r VERNEED 0000000000000dd0 000dd0 000070 00 A 4 2 8
[ 8] .rela.dyn RELA 0000000000000e40 000e40 007bd8 18 A 3 0 8
[ 9] .rela.plt RELA 0000000000008a18 008a18 0005b8 18 A 3 26 8
[10] .init PROGBITS 0000000000008fd0 008fd0 000058 00 AX 0 0 8
[11] .text PROGBITS 0000000000009030 009030 03b1a8 00 AX 0 0 16
[12] .fini PROGBITS 00000000000441d8 0441d8 000028 00 AX 0 0 8
[13] .rodata PROGBITS 0000000000044200 044200 013bb0 00 A 0 0 8
[14] .eh_frame_hdr PROGBITS 0000000000057db0 057db0 000e5c 00 A 0 0 4
[15] .eh_frame PROGBITS 0000000000058c10 058c10 004f04 00 A 0 0 8
[16] .ctors PROGBITS 0000000000060000 060000 000010 00 WA 0 0 8
[17] .dtors PROGBITS 0000000000060010 060010 000018 00 WA 0 0 8
[18] .jcr PROGBITS 0000000000060028 060028 000008 00 WA 0 0 8
[19] .data.rel.ro PROGBITS 0000000000060030 060030 0007a8 00 WA 0 0 8
[20] .dynamic DYNAMIC 00000000000607d8 0607d8 0001e0 10 WA 4 0 8
[21] .data PROGBITS 00000000000609b8 0609b8 000024 00 WA 0 0 8
[22] .toc1 PROGBITS 00000000000609e0 0609e0 000418 00 WA 0 0 8
[23] .opd PROGBITS 0000000000060df8 060df8 001cf8 00 WA 0 0 8
[24] .branch_lt PROGBITS 0000000000062af0 062af0 000000 00 WA 0 0 8
[25] .got PROGBITS 0000000000062af0 062af0 000130 08 WA 0 0 8
[26] .plt NOBITS 0000000000062c20 062c20 0005d0 18 WA 0 0 8
[27] .bss NOBITS 00000000000631f0 062c20 004490 00 WA 0 0 8
[28] .comment PROGBITS 0000000000000000 062c20 000059 01 MS 0 0 1
[29] .debug_aranges PROGBITS 0000000000000000 062c79 000630 00 0 0 1
[30] .debug_pubnames PROGBITS 0000000000000000 0632a9 002088 00 0 0 1
[31] .debug_info PROGBITS 0000000000000000 065331 0246a2 00 0 0 1
[32] .debug_abbrev PROGBITS 0000000000000000 0899d3 004c0b 00 0 0 1
[33] .debug_line PROGBITS 0000000000000000 08e5de 00b8cf 00 0 0 1
[34] .debug_str PROGBITS 0000000000000000 099ead 006261 01 MS 0 0 1
[35] .debug_loc PROGBITS 0000000000000000 0a010e 034c46 00 0 0 1
[36] .debug_pubtypes PROGBITS 0000000000000000 0d4d54 002f3a 00 0 0 1
[37] .debug_ranges PROGBITS 0000000000000000 0d7c8e 00a7a0 00 0 0 1
[38] .shstrtab STRTAB 0000000000000000 0e242e 00018a 00 0 0 1
[39] .symtab SYMTAB 0000000000000000 0e2ff8 004a10 18 40 713 8
[40] .strtab STRTAB 0000000000000000 0e7a08 00316d 00 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 DYN (Shared object file)
Entry point 0x60df8
There are 6 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x05db14 0x05db14 R E 0x10000
LOAD 0x060000 0x0000000000060000 0x0000000000060000 0x002c20 0x007680 RW 0x10000
DYNAMIC 0x0607d8 0x00000000000607d8 0x00000000000607d8 0x0001e0 0x0001e0 RW 0x8
NOTE 0x000190 0x0000000000000190 0x0000000000000190 0x000024 0x000024 R 0x4
GNU_EH_FRAME 0x057db0 0x0000000000057db0 0x0000000000057db0 0x000e5c 0x000e5c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x8
Section to Segment mapping:
Segment Sections...
00 .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rela.dyn .rela.plt .init .text .fini .rodata .eh_frame_hdr .eh_frame
01 .ctors .dtors .jcr .data.rel.ro .dynamic .data .toc1 .opd .got .plt .bss
02 .dynamic
03 .note.gnu.build-id
04 .eh_frame_hdr
05
$ binutils/objcopy libfreebl3.so libfreebl3.so-copy
$ diff -u <(binutils/readelf -WSl libfreebl3.so) <(binutils/readelf -WSl libfreebl3.so-copy)
--- /proc/self/fd/63 2010-07-15 15:37:37.162244967 +0200
+++ /proc/self/fd/62 2010-07-15 15:37:37.163244682 +0200
@@ -26,7 +26,7 @@
[21] .data PROGBITS 00000000000609b8 0609b8 000024 00 WA 0 0 8
[22] .toc1 PROGBITS 00000000000609e0 0609e0 000418 00 WA 0 0 8
[23] .opd PROGBITS 0000000000060df8 060df8 001cf8 00 WA 0 0 8
- [24] .branch_lt PROGBITS 0000000000062af0 062af0 000000 00 WA 0 0 8
+ [24] .branch_lt PROGBITS 0000000000062af0 062c20 000000 00 WA 0 0 8
[25] .got PROGBITS 0000000000062af0 062af0 000130 08 WA 0 0 8
[26] .plt NOBITS 0000000000062c20 062c20 0005d0 18 WA 0 0 8
[27] .bss NOBITS 00000000000631f0 062c20 004490 00 WA 0 0 8
The sh_offset of .branch_lt no longer agrees with sh_addr modulo segment
alignment.
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."