Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <3H3RZMWMHJWF6.2TNTY77S3OQ7F@mforney.org>
Date: Sun, 15 Mar 2026 02:37:21 -0700
From: Michael Forney <mforney@...rney.org>
To: i@...kray.me
Cc: musl@...ts.openwall.com
Subject: Re: ld-musl-* and empty .eh_frame

Fangrui Song <i@...kray.me> wrote:
> On 2021-03-05, Michael Forney wrote:
> >On 2021-03-05, Fangrui Song <i@...kray.me> wrote:
> >> The empty .eh_frame is suspicious, though. There may be two problems:
> >>
> >> 1. Why do you have an empty .eh_frame in an object file
> >
> >There is no .eh_frame in any of the object files involved (neither t.o
> >or crt*.o), just in the final executable. It seems that GNU ld creates
> >a .eh_frame section unless you pass --no-ld-generated-unwind-info.
> >
> >> 2. Why does ld.bfd create empty .eh_frame in that case (I have tried
> >>    simple examples like  `.section .eh_frame,"a"` and I cannot reproduce
> >>    the empty output .eh_frame)
> >>
> >> If you don't share the other files, it is difficult to locate the
> >> problem.
> >
> >Which files are you interested in? The recipe I showed earlier should
> >be sufficient to reproduce the issue. You can use the standard alpine
> >linux toolchain (using /usr/lib instead of /lib for the paths to the
> >crt*.o files). With a musl.cc toolchain, you'll need to pass -z
> >separate-code to get the empty PT_LOAD segment, but the empty
> >.eh_frame is there either way.
> 
> You can build ld from the upstream binutils-gdb repo.
> after configure, run `make -j30 all-ld` and use ld/ld-new.
> 
> If you can reproduce, p_memsz==0 PT_LOAD in -z separate-code case deserves a bug.

I had completely forgotten about this, but I randomly stumbled upon
this thread again and thought I'd follow up.

I checked and it's still an issue with latest binutils git (though
somewhat hidden due to a recent change in .note.gnu.property
handling).

Here is how you can reproduce:

$ cat >t.s <<'EOF'
.text
.globl _start
_start:
	mov $60, %rax
	mov $123, %rdi
	syscall
EOF
$ as -o t.o t.s
$ objcopy -R .note.gnu.property t.o t2.o
$ ld -shared -o a.so /dev/null
$ ld --no-dynamic-linker -o t t2.o a.so
$ readelf -l t
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
<snip>
  LOAD           0x0000000000002000 0x0000000000402000 0x0000000000402000
                 0x0000000000000000 0x0000000000000000  R      0x1000
<snip>
$ readelf -S t
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
<snip>
  [ 7] .eh_frame         PROGBITS         0000000000402000  00002000
       0000000000000000  0000000000000000   A       0     0     8
<snip>
$

Just wanted confirm with you that this is a bug before filing an
issue on the binutils bug tracker.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.