public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Max Larsson <max.larsson@gmx.de>
Cc: binutils@sourceware.org
Subject: Re: Overlapping program headers/segments
Date: Mon, 25 Sep 2023 08:14:03 +0200	[thread overview]
Message-ID: <98b38195-bd91-b7a5-f7ba-00760da90de1@suse.com> (raw)
In-Reply-To: <trinity-363cade1-ec18-43c7-a03b-4bac3a674e21-1695580324668@3c-app-gmx-bs51>

On 24.09.2023 20:32, Max Larsson via Binutils wrote:
> What I have done so far, is to put the .rodata section in its own segment via defining a target
> specific method for 'elf_backend_modify_segment'. How to do it, I copied/looked/adapted from
> elfxx-mips.c:_bfd_mips_elf_modify_segment_map That works as expected.
>  
> But The result is that the program headers overlap. Like this:
>  
> Program Headers:
>   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD           0x000000 0x10000000 0x10000000 0x02034 0x02034 R E 0x10000
>   LOAD           0x020000 0x10010000 0x10010000 0x000f0 0x000f0 RW  0x10000
>   DYNAMIC        0x020028 0x10010028 0x10010028 0x000b8 0x000b8 RW  0x4
>   LOAD           0x012000 0x10002000 0x10002000 0x00031 0x00031 R   0x10000
>  Section to Segment mapping:
>   Segment Sections...
>    00     .hash .dynsym .dynstr .rela.dyn .rela.got2 .rela.plt .text .plt
>    01     .init_array .fini_array .got2 .dynamic .got
>    02     .dynamic
>    03     .rodata
>  
> You see, if you take the Virt-/PhysAddr and add the MemSize from the first
> program header the result is 0x10002034, which is greater than the Virt-/PhysAddr
> of the last program header   0x10002000.
> 
> So my question why do I get such a result, and how can I avoid it?

You didn't provide the linker script, which may have the observed effect together
with your code change: If it puts .text and .rodata together, then the overlap is
to be expected (as would frequently happen for NOTE segments and .note sections),
I think.

Jan

  reply	other threads:[~2023-09-25  6:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-24 18:32 Max Larsson
2023-09-25  6:14 ` Jan Beulich [this message]
2023-09-25  7:24 ` Andreas Schwab
2023-09-28  7:25   ` Max Larsson

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=98b38195-bd91-b7a5-f7ba-00760da90de1@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=max.larsson@gmx.de \
    /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).