[Bug 227552] w, uptime i386 coredump in libxo

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri May 11 17:22:11 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227552

--- Comment #24 from Phil Shafer <phil at freebsd.org> ---
I'm looking into why readelf output differs between the stripped and unstripped
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 = 0; (size_t)i < phnum; i++) {
2374                    if (gelf_getphdr(re->elf, i, &phdr) != &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 = 1; (size_t)j < re->shnum; j++)
2381                            if (re->sl[j].addr >= phdr.p_vaddr &&
2382                                re->sl[j].addr + re->sl[j].sz <=
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 == 3 and j == 15.

For the unstripped library (the working one):

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

Both conditions are true.

For the stripped library (the failing one):

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

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


More information about the freebsd-bugs mailing list