public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Andreas Schwab <schwab@redhat.com>
Cc: David Stubbs <stubbs@icerasemi.com>, binutils@sourceware.org
Subject: Re: VMA section overlap warnings for overlays
Date: Thu, 15 Jul 2010 13:53:00 -0000	[thread overview]
Message-ID: <AANLkTikCxGTUKa9ovu7sqxD6S3dTY766X1WM-oRrm5Ek@mail.gmail.com> (raw)
In-Reply-To: <m3lj9cx3gr.fsf@hase.home>

On Thu, Jul 15, 2010 at 6:46 AM, Andreas Schwab <schwab@redhat.com> wrote:
> 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.
>

What is an empty section used for?

-- 
H.J.

  reply	other threads:[~2010-07-15 13:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 13:29 David Stubbs
2010-04-21  8:25 ` Alan Modra
2010-04-21 14:44   ` David Stubbs
2010-04-22  1:11     ` Alan Modra
2010-04-22  1:53       ` Alan Modra
2010-04-22 12:39         ` David Stubbs
2010-04-24  2:18           ` Alan Modra
2010-05-07 16:14             ` David Stubbs
2010-05-08 11:49               ` Alan Modra
2010-05-12 13:19                 ` David Stubbs
2010-05-13  3:37                   ` Alan Modra
2010-07-15  8:11             ` Andreas Schwab
2010-07-15 13:10               ` Alan Modra
2010-07-15 13:46                 ` Andreas Schwab
2010-07-15 13:53                   ` H.J. Lu [this message]
2010-07-15 14:12                     ` Andreas Schwab
2010-07-15 14:17                       ` H.J. Lu
2010-07-15 14:18                     ` Alan Modra
2010-07-15 14:26                       ` H.J. Lu
2010-07-15 14:36                         ` Andreas Schwab
2010-07-15 19:09                           ` H.J. Lu
2010-07-16  7:39                             ` Andreas Schwab
2010-07-16 10:04                               ` Alan Modra
2010-07-19 12:43                                 ` Andreas Schwab
2010-07-20  5:45                                   ` Alan Modra
2010-07-20 14:11                                     ` Alan Modra
2011-02-24 23:49                                       ` H.J. Lu
2011-02-25  7:49                                         ` Alan Modra
2011-02-25 10:17                                           ` Andreas Schwab
2011-02-25 12:30                                           ` H.J. Lu
2011-02-25 15:55                                           ` H.J. Lu
2011-02-25 16:23                                             ` Andreas Schwab
2011-02-25 16:34                                               ` H.J. Lu
2010-08-28  1:02         ` H.J. Lu
2010-08-28 11:00           ` Alan Modra
2010-08-28 13:39             ` Alan Modra
2010-08-28 17:25               ` H.J. Lu
2010-08-30  4:46                 ` Alan Modra
2010-08-30  5:11                   ` H.J. Lu
2010-08-30  6:30                     ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTikCxGTUKa9ovu7sqxD6S3dTY766X1WM-oRrm5Ek@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=schwab@redhat.com \
    --cc=stubbs@icerasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).