Summary: | btxld does not handle input with other than 2 PT_LOAD segments | ||
---|---|---|---|
Product: | Base System | Reporter: | Ed Maste <emaste> |
Component: | bin | Assignee: | Ed Maste <emaste> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | CC: | imp |
Priority: | --- | Flags: | koobs:
mfc-stable11+
|
Version: | CURRENT | ||
Hardware: | Any | ||
OS: | Any |
Description
Ed Maste
![]() ![]() Just curious, why the boot code may need more than two segments. It would be interesting to see readelf or objdump output for zfsloader.bin. It is because lld collects read-only contents into a separate segment, for example: % readelf -l zfsloader.sym Elf file type is EXEC (Executable file) Entry point 0x0 There are 5 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x00000000 0x00000000 0x58694 0x58694 R E 0x1000 LOAD 0x05a000 0x00059000 0x00059000 0x0afcc 0x0afcc R 0x1000 LOAD 0x065000 0x00064000 0x00064000 0x07854 0x14c9c RW 0x1000 GNU_RELRO 0x06c000 0x0006b000 0x0006b000 0x00854 0x01000 R 0x1 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0 Section to Segment mapping: Segment Sections... 00 .text .gnu_debuglink .comment .debug_str .debug_loc .debug_abbrev .debug_info .debug_ranges .debug_macinfo .debug_pubnames .debug_pubtypes .debug_frame .debug_line .debug_aranges .symtab .shstrtab .strtab 01 .rodata set_Xcommand_set 02 .data set_Xficl_compile_set .data.rel.ro .got .bss 03 .data.rel.ro .got 04 Linking with -z norelro leaves the three PT_LOADs, just the PT_GNU_RELRO is not emitted. From the output above btxld should coalesce two PT_LOADs, and discarding a PT_LOAD should be an error not a warning. See https://reviews.freebsd.org/D14956, which stops lld from generating > 2 PT_LOADs. The underlying issue in btxld will still exist. IMO we should upgrade the warning btxld: zfsloader.bin: Warning: Ignoring extra elf PT_LOAD segments to an error to ensure we won't silently ignore segments in the future, and such a change is sufficient to resolve this. A commit references this bug: Author: emaste Date: Fri Apr 6 02:57:59 UTC 2018 New revision: 332090 URL: https://svnweb.freebsd.org/changeset/base/332090 Log: stand: pass --no-rosegment for i386 bits when linking with lld btxld does not correctly handle input with other than 2 PT_LOAD segments. Passing --no-rosegment lets lld produce output eqivalent to ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. PR: 225775 MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D14956 Changes: head/stand/i386/Makefile.inc A commit references this bug: Author: emaste Date: Fri Apr 27 01:21:52 UTC 2018 New revision: 333048 URL: https://svnweb.freebsd.org/changeset/base/333048 Log: MFC r332090: stand: pass --no-rosegment for i386 bits when linking with lld btxld does not correctly handle input with other than 2 PT_LOAD segments. Passing --no-rosegment lets lld produce output eqivalent to ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. PR: 225775 Sponsored by: The FreeBSD Foundation Changes: _U stable/11/ stable/11/stand/i386/Makefile.inc Fix commited, closing |