Bug ID: 30415
           Summary: lld has different section attribute merging vs ld.bfd
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
            Blocks: 23214
    Classification: Unclassified

LLD is not necessarily wrong here and what ld.bfd is doing is arguably a bug,
but I'm submitting this PR for tracking one of the few outstanding issues
linking FreeBSD/amd64 with LLD while looking for a solution.

We recently migrated to using a linker script instead of the seemingly obsolete
-N command line flag for FreeBSD's boot loader components:

The linker script is straightforward:

/* $FreeBSD$ */
/* Merge text, data and bss together almost no padding */
  . = 0x08048000 + SIZEOF_HEADERS;
  .text : { *(.text) } =0x90909090      /* Pad with nops, if needed */
  .data : { *(.data) } PROVIDE(_edata = .);
  .bss  : { *(.bss) }  PROVIDE(_end = .);

>From this GNU ld produces an object with all sections packed into a single RWE

% readelf -l boot2.out

Elf file type is EXEC (Executable file)
Entry point 0x2000
There are 2 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000080 0x00002000 0x00002000 0x01456 0x027f8 RWE 0x10
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .data .bss 

while LLD produces an object with separate segments for sections with different

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to