mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Michael Forney <mforney@mforney.org>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>
Subject: Re: [musl] ld-musl-* and empty .eh_frame
Date: Fri, 5 Mar 2021 17:30:37 -0800	[thread overview]
Message-ID: <CAGw6cBsHaJez_rmGY8Gvkou4gR6bY1p7=ykKeyZkZ5UFaWuPog@mail.gmail.com> (raw)
In-Reply-To: <20210306011405.g5t2pncdcbh4ebij@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

On 2021-03-05, Fangrui Song <i@maskray.me> wrote:
> Can you clarify how GNU ld creates an empty .eh_frame?

Sure, see the shell snippet in my original post.

> The program header PT_GNU_EH_FRAME is created from .eh_frame_hdr, which
> is created by ld --eh-frame-hdr.
> If .eh_frame is empty, from my observation GNU ld does not create
> .eh_frame_hdr

There is no PT_GNU_EH_FRAME in the executables. Based on Rich's
explanation earlier, my understanding is that the issue is that GNU ld
creates a empty PT_LOAD segment for the empty .eh_frame section.

I attached the output of readelf -l in case that is helpful.

> https://maskray.me/blog/2020-11-08-stack-unwinding#eh_frame_hdr-and-pt_eh_frame
>
>>I'm not too familiar with the binutils codebase, but I can try. As far
>>as I can tell, the alignment is set to at least the maximum page size:
>>https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf.c;h=84a5d942817a9a54b1170fbbb594787c5839aa54;hb=f35674005e609660f5f45005a9e095541ca4c5fe#l5601
>
> max-page-size is for layouting PT_LOAD.
> It is unrelated to PT_GNU_EH_FRAME.

The empty PT_LOAD segment is the issue here, not PT_GNU_EH_FRAME.

> The requirement is
> http://www.sco.com/developers/gabi/latest/ch5.pheader.html
> "p_vaddr should equal p_offset, modulo p_align."
>
> p_vaddr % p_align != 0 is valid.
>
> p_memsz can be zero.

Are you saying that GNU ld might create PT_LOAD segments with zero
size, and unaligned p_vaddr? If that's the case, I think Rich might
have a valid concern here.

[-- Attachment #2: t-readelf.txt --]
[-- Type: text/plain, Size: 1891 bytes --]


Elf file type is EXEC (Executable file)
Entry point 0x401020
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R      0x8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x0000000000000019 0x0000000000000019  R      0x1
      [Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000000348 0x0000000000000348  R      0x1000
  LOAD           0x0000000000001000 0x0000000000401000 0x0000000000401000
                 0x0000000000000060 0x0000000000000060  R E    0x1000
  LOAD           0x0000000000002000 0x0000000000402000 0x0000000000402000
                 0x0000000000000000 0x0000000000000000  R      0x1000
  LOAD           0x0000000000002e90 0x0000000000402e90 0x0000000000402e90
                 0x0000000000000190 0x0000000000000190  RW     0x1000
  DYNAMIC        0x0000000000002e90 0x0000000000402e90 0x0000000000402e90
                 0x0000000000000160 0x0000000000000160  RW     0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    0x10
  GNU_RELRO      0x0000000000002e90 0x0000000000402e90 0x0000000000402e90
                 0x0000000000000170 0x0000000000000170  R      0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .gnu.hash .dynsym .dynstr .rela.dyn .rela.plt 
   03     .plt .text 
   04     .eh_frame 
   05     .dynamic .got .got.plt 
   06     .dynamic 
   07     
   08     .dynamic .got 

  parent reply	other threads:[~2021-03-06  1:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  3:18 Michael Forney
2021-03-05 15:07 ` Rich Felker
2021-03-05 16:12   ` Rich Felker
2021-03-05 22:53     ` Michael Forney
2021-03-06  1:14       ` Fangrui Song
2021-03-06  1:28         ` Rich Felker
2021-03-06  1:30         ` Michael Forney [this message]
2021-03-06  1:39           ` Fangrui Song
2021-03-06  2:04             ` Michael Forney
2021-03-06  2:09               ` Fangrui Song

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='CAGw6cBsHaJez_rmGY8Gvkou4gR6bY1p7=ykKeyZkZ5UFaWuPog@mail.gmail.com' \
    --to=mforney@mforney.org \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).