From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6628 invoked by alias); 15 Jul 2010 13:53:50 -0000 Received: (qmail 6615 invoked by uid 22791); 15 Jul 2010 13:53:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-pw0-f41.google.com (HELO mail-pw0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Jul 2010 13:53:43 +0000 Received: by pwi8 with SMTP id 8so682452pwi.0 for ; Thu, 15 Jul 2010 06:53:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.147.20 with SMTP id u20mr23575496wfd.132.1279202019741; Thu, 15 Jul 2010 06:53:39 -0700 (PDT) Received: by 10.142.226.18 with HTTP; Thu, 15 Jul 2010 06:53:39 -0700 (PDT) In-Reply-To: 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> <20100715130955.GH31087@bubble.grove.modra.org> Date: Thu, 15 Jul 2010 13:53:00 -0000 Message-ID: Subject: Re: VMA section overlap warnings for overlays From: "H.J. Lu" To: Andreas Schwab Cc: David Stubbs , binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00187.txt.bz2 On Thu, Jul 15, 2010 at 6:46 AM, Andreas Schwab wrote: > Alan Modra writes: > >> On Thu, Jul 15, 2010 at 10:11:03AM +0200, Andreas Schwab wrote: >>> Alan Modra writes: >>> >>> > @@ -5837,7 +5853,8 @@ copy_elf_program_header (bfd *ibfd, bfd >>> > =A0 =A0 =A0 section =3D section->next) >>> > =A0 =A0{ >>> > =A0 =A0 =A0this_hdr =3D &(elf_section_data(section)->this_hdr); >>> > - =A0 =A0if (ELF_IS_SECTION_IN_SEGMENT_FILE (this_hdr, segment)) >>> > + =A0 =A0if (this_hdr->sh_size !=3D 0 >>> > + =A0 =A0 =A0 =A0&& ELF_SECTION_IN_SEGMENT (this_hdr, segment)) >>> >>> Why can't an empty section never be part of a segment? >> >> Good question. =A0I 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: > =A0[Nr] Name =A0 =A0 =A0 =A0 =A0 =A0 =A0Type =A0 =A0 =A0 =A0 =A0 =A0Addre= ss =A0 =A0 =A0 =A0 =A0Off =A0 =A0Size =A0 ES Flg Lk Inf Al > =A0[ 0] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NULL =A0 =A0 =A0 =A0 =A0 =A00= 000000000000000 000000 000000 00 =A0 =A0 =A00 =A0 0 =A00 > =A0[ 1] .note.gnu.build-id NOTE =A0 =A0 =A0 =A0 =A0 =A00000000000000190 0= 00190 000024 00 =A0 A =A00 =A0 0 =A04 > =A0[ 2] .gnu.hash =A0 =A0 =A0 =A0 GNU_HASH =A0 =A0 =A0 =A000000000000001b= 8 0001b8 000050 00 =A0 A =A03 =A0 0 =A08 > =A0[ 3] .dynsym =A0 =A0 =A0 =A0 =A0 DYNSYM =A0 =A0 =A0 =A0 =A000000000000= 00208 000208 000798 18 =A0 A =A04 =A0 3 =A08 > =A0[ 4] .dynstr =A0 =A0 =A0 =A0 =A0 STRTAB =A0 =A0 =A0 =A0 =A000000000000= 009a0 0009a0 000336 00 =A0 A =A00 =A0 0 =A01 > =A0[ 5] .gnu.version =A0 =A0 =A0VERSYM =A0 =A0 =A0 =A0 =A00000000000000cd= 6 000cd6 0000a2 02 =A0 A =A03 =A0 0 =A02 > =A0[ 6] .gnu.version_d =A0 =A0VERDEF =A0 =A0 =A0 =A0 =A00000000000000d78 = 000d78 000054 00 =A0 A =A04 =A0 3 =A08 > =A0[ 7] .gnu.version_r =A0 =A0VERNEED =A0 =A0 =A0 =A0 0000000000000dd0 00= 0dd0 000070 00 =A0 A =A04 =A0 2 =A08 > =A0[ 8] .rela.dyn =A0 =A0 =A0 =A0 RELA =A0 =A0 =A0 =A0 =A0 =A000000000000= 00e40 000e40 007bd8 18 =A0 A =A03 =A0 0 =A08 > =A0[ 9] .rela.plt =A0 =A0 =A0 =A0 RELA =A0 =A0 =A0 =A0 =A0 =A000000000000= 08a18 008a18 0005b8 18 =A0 A =A03 =A026 =A08 > =A0[10] .init =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A000000000000= 08fd0 008fd0 000058 00 =A0AX =A00 =A0 0 =A08 > =A0[11] .text =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A000000000000= 09030 009030 03b1a8 00 =A0AX =A00 =A0 0 16 > =A0[12] .fini =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A000000000000= 441d8 0441d8 000028 00 =A0AX =A00 =A0 0 =A08 > =A0[13] .rodata =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000044= 200 044200 013bb0 00 =A0 A =A00 =A0 0 =A08 > =A0[14] .eh_frame_hdr =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000057db0 05= 7db0 000e5c 00 =A0 A =A00 =A0 0 =A04 > =A0[15] .eh_frame =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000058c1= 0 058c10 004f04 00 =A0 A =A00 =A0 0 =A08 > =A0[16] .ctors =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A000000000000= 60000 060000 000010 00 =A0WA =A00 =A0 0 =A08 > =A0[17] .dtors =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A000000000000= 60010 060010 000018 00 =A0WA =A00 =A0 0 =A08 > =A0[18] .jcr =A0 =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A0000000000= 0060028 060028 000008 00 =A0WA =A00 =A0 0 =A08 > =A0[19] .data.rel.ro =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000060030 = 060030 0007a8 00 =A0WA =A00 =A0 0 =A08 > =A0[20] .dynamic =A0 =A0 =A0 =A0 =A0DYNAMIC =A0 =A0 =A0 =A0 0000000000060= 7d8 0607d8 0001e0 10 =A0WA =A04 =A0 0 =A08 > =A0[21] .data =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A000000000000= 609b8 0609b8 000024 00 =A0WA =A00 =A0 0 =A08 > =A0[22] .toc1 =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A000000000000= 609e0 0609e0 000418 00 =A0WA =A00 =A0 0 =A08 > =A0[23] .opd =A0 =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A0000000000= 0060df8 060df8 001cf8 00 =A0WA =A00 =A0 0 =A08 > =A0[24] .branch_lt =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000062af= 0 062af0 000000 00 =A0WA =A00 =A0 0 =A08 > =A0[25] .got =A0 =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A0000000000= 0062af0 062af0 000130 08 =A0WA =A00 =A0 0 =A08 > =A0[26] .plt =A0 =A0 =A0 =A0 =A0 =A0 =A0NOBITS =A0 =A0 =A0 =A0 =A00000000= 000062c20 062c20 0005d0 18 =A0WA =A00 =A0 0 =A08 > =A0[27] .bss =A0 =A0 =A0 =A0 =A0 =A0 =A0NOBITS =A0 =A0 =A0 =A0 =A00000000= 0000631f0 062c20 004490 00 =A0WA =A00 =A0 0 =A08 > =A0[28] .comment =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000000= 000 062c20 000059 01 =A0MS =A00 =A0 0 =A01 > =A0[29] .debug_aranges =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000000000 06= 2c79 000630 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[30] .debug_pubnames =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 0632= a9 002088 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[31] .debug_info =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 = 065331 0246a2 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[32] .debug_abbrev =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 08= 99d3 004c0b 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[33] .debug_line =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 = 08e5de 00b8cf 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[34] .debug_str =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A0000000000000000= 0 099ead 006261 01 =A0MS =A00 =A0 0 =A01 > =A0[35] .debug_loc =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A0000000000000000= 0 0a010e 034c46 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[36] .debug_pubtypes =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 0d4d= 54 002f3a 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[37] .debug_ranges =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000000000 0d= 7c8e 00a7a0 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[38] .shstrtab =A0 =A0 =A0 =A0 STRTAB =A0 =A0 =A0 =A0 =A00000000000000= 000 0e242e 00018a 00 =A0 =A0 =A00 =A0 0 =A01 > =A0[39] .symtab =A0 =A0 =A0 =A0 =A0 SYMTAB =A0 =A0 =A0 =A0 =A000000000000= 00000 0e2ff8 004a10 18 =A0 =A0 40 713 =A08 > =A0[40] .strtab =A0 =A0 =A0 =A0 =A0 STRTAB =A0 =A0 =A0 =A0 =A000000000000= 00000 0e7a08 00316d 00 =A0 =A0 =A00 =A0 0 =A01 > Key to Flags: > =A0W (write), A (alloc), X (execute), M (merge), S (strings) > =A0I (info), L (link order), G (group), x (unknown) > =A0O (extra OS processing required) o (OS specific), p (processor specifi= c) > > Elf file type is DYN (Shared object file) > Entry point 0x60df8 > There are 6 program headers, starting at offset 64 > > Program Headers: > =A0Type =A0 =A0 =A0 =A0 =A0 Offset =A0 VirtAddr =A0 =A0 =A0 =A0 =A0 PhysA= ddr =A0 =A0 =A0 =A0 =A0 FileSiz =A0MemSiz =A0 Flg Align > =A0LOAD =A0 =A0 =A0 =A0 =A0 0x000000 0x0000000000000000 0x000000000000000= 0 0x05db14 0x05db14 R E 0x10000 > =A0LOAD =A0 =A0 =A0 =A0 =A0 0x060000 0x0000000000060000 0x000000000006000= 0 0x002c20 0x007680 RW =A00x10000 > =A0DYNAMIC =A0 =A0 =A0 =A00x0607d8 0x00000000000607d8 0x00000000000607d8 = 0x0001e0 0x0001e0 RW =A00x8 > =A0NOTE =A0 =A0 =A0 =A0 =A0 0x000190 0x0000000000000190 0x000000000000019= 0 0x000024 0x000024 R =A0 0x4 > =A0GNU_EH_FRAME =A0 0x057db0 0x0000000000057db0 0x0000000000057db0 0x000e= 5c 0x000e5c R =A0 0x4 > =A0GNU_STACK =A0 =A0 =A00x000000 0x0000000000000000 0x0000000000000000 0x= 000000 0x000000 RW =A00x8 > > =A0Section to Segment mapping: > =A0Segment Sections... > =A0 00 =A0 =A0 .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 > =A0 01 =A0 =A0 .ctors .dtors .jcr .data.rel.ro .dynamic .data .toc1 .opd = .got .plt .bss > =A0 02 =A0 =A0 .dynamic > =A0 03 =A0 =A0 .note.gnu.build-id > =A0 04 =A0 =A0 .eh_frame_hdr > =A0 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 =A0 =A02010-07-15 15:37:37.162244967 +0200 > +++ /proc/self/fd/62 =A0 =A02010-07-15 15:37:37.163244682 +0200 > @@ -26,7 +26,7 @@ > =A0 [21] .data =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000= 0609b8 0609b8 000024 00 =A0WA =A00 =A0 0 =A08 > =A0 [22] .toc1 =A0 =A0 =A0 =A0 =A0 =A0 PROGBITS =A0 =A0 =A0 =A00000000000= 0609e0 0609e0 000418 00 =A0WA =A00 =A0 0 =A08 > =A0 [23] .opd =A0 =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A000000000= 00060df8 060df8 001cf8 00 =A0WA =A00 =A0 0 =A08 > - =A0[24] .branch_lt =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000062= af0 062af0 000000 00 =A0WA =A00 =A0 0 =A08 > + =A0[24] .branch_lt =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A00000000000062= af0 062c20 000000 00 =A0WA =A00 =A0 0 =A08 > =A0 [25] .got =A0 =A0 =A0 =A0 =A0 =A0 =A0PROGBITS =A0 =A0 =A0 =A000000000= 00062af0 062af0 000130 08 =A0WA =A00 =A0 0 =A08 > =A0 [26] .plt =A0 =A0 =A0 =A0 =A0 =A0 =A0NOBITS =A0 =A0 =A0 =A0 =A0000000= 0000062c20 062c20 0005d0 18 =A0WA =A00 =A0 0 =A08 > =A0 [27] .bss =A0 =A0 =A0 =A0 =A0 =A0 =A0NOBITS =A0 =A0 =A0 =A0 =A0000000= 00000631f0 062c20 004490 00 =A0WA =A00 =A0 0 =A08 > > The sh_offset of .branch_lt no longer agrees with sh_addr modulo segment > alignment. > What is an empty section used for? --=20 H.J.