https://llvm.org/bugs/show_bug.cgi?id=30415

            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
          Assignee: unassignedb...@nondot.org
          Reporter: ema...@freebsd.org
                CC: llvm-bugs@lists.llvm.org
            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:
https://svnweb.freebsd.org/base?view=revision&revision=305353

The linker script is straightforward:

---
/* $FreeBSD$ */
/* Merge text, data and bss together almost no padding */
OUTPUT_FORMAT("elf32-i386-freebsd")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS {
  . = 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
segment:

% 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 
   01     

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to