Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 May 2018 17:22:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 227552] w, uptime i386 coredump in libxo
Message-ID:  <bug-227552-227-YGPHgrI5ct@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-227552-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-227552-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D227552

--- Comment #24 from Phil Shafer <phil@freebsd.org> ---
I'm looking into why readelf output differs between the stripped and unstri=
pped
versions of the library, per comment #20.  readelf.c:2381 has the following
code:

2371            printf("\n Section to Segment mapping:\n");
2372            printf("  Segment Sections...\n");
2373            for (i =3D 0; (size_t)i < phnum; i++) {
2374                    if (gelf_getphdr(re->elf, i, &phdr) !=3D &phdr) {
2375                            warnx("gelf_getphdr failed: %s",
elf_errmsg(-1));
2376                            continue;
2377                    }
2378                    printf("   %2.2d     ", i);
2379                    /* skip NULL section. */
2380                    for (j =3D 1; (size_t)j < re->shnum; j++)
2381                            if (re->sl[j].addr >=3D phdr.p_vaddr &&
2382                                re->sl[j].addr + re->sl[j].sz <=3D
2383                                phdr.p_vaddr + phdr.p_memsz)
2384                                    printf("%s ", re->sl[j].name);
2385                    printf("\n");

For the unstripped library, the output is:

 Section to Segment mapping:
  Segment Sections...
   00     .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.=
dyn
.rel.plt .init .plt .text .fini .rodata .eh_frame .comment .debug_pubnames
.debug_info .debug_abbrev .debug_line .debug_frame .debug_str .debug_loc
.debug_macinfo .debug_pubtypes .debug_ranges .shstrtab .symtab .strtab
   01     .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .bss
   02     .dynamic
   03     .tbss .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data
.bss
   04

where the stripped library says:

 Section to Segment mapping:
  Segment Sections...
   00     .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.=
dyn
.rel.plt .init .plt .text .fini .rodata .eh_frame .comment .shstrtab
   01     .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .bss
   02     .dynamic
   03     .bss
   04

So I breakpointed on line 2381 when i =3D=3D 3 and j =3D=3D 15.

For the unstripped library (the working one):

(gdb) p re->sl[j]
$18 =3D {name =3D 0x28626087 ".tbss", scn =3D 0x28621780, off =3D 94712, sz=
 =3D 1624,
entsize =3D 0,
  align =3D 8, type =3D 8, flags =3D 1027, addr =3D 98808, link =3D 0, info=
 =3D 0}
(gdb) p phdr
$19 =3D {p_type =3D 7, p_flags =3D 4, p_offset =3D 94712, p_vaddr =3D 98808=
, p_paddr =3D
98808,
  p_filesz =3D 0, p_memsz =3D 1624, p_align =3D 8}
(gdb) p (re->sl[j].addr >=3D phdr.p_vaddr)
$20 =3D 1
(gdb) p (re->sl[j].addr + re->sl[j].sz <=3D phdr.p_vaddr + phdr.p_memsz)
$21 =3D 1

Both conditions are true.

For the stripped library (the failing one):

(gdb) p re->sl[j]
$13 =3D {name =3D 0x28621077 ".tbss", scn =3D 0x2861d780, off =3D 94712, sz=
 =3D 1624,
entsize =3D 0,
  align =3D 8, type =3D 8, flags =3D 1027, addr =3D 98808, link =3D 0, info=
 =3D 0}
(gdb) p phdr
$15 =3D {p_type =3D 7, p_flags =3D 4, p_offset =3D 94712, p_vaddr =3D 10034=
0, p_paddr =3D
100340,
  p_filesz =3D 0, p_memsz =3D 80, p_align =3D 8}
(gdb) p (re->sl[j].addr >=3D phdr.p_vaddr)
$14 =3D 0

The section's address (98808) is less than the segment's (100340), so
the section is no longer listed.

Perhaps is strip not updating the addresses as it removes sections?  Or is
there a disagreement between clang-6 and binutils about elf layout?

Thanks,
 Phil

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-227552-227-YGPHgrI5ct>