[llvm-bugs] [Bug 43083] New: [linker script] dot should be relative to memory region's origin

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 22 01:04:06 PDT 2019


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

            Bug ID: 43083
           Summary: [linker script] dot should be relative to memory
                    region's origin
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: ruiu at google.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

The following test demonstrates an issue of the lld's linker script processor.

BFD linker handles the dot in a memory region as a relative address from the
beginning of the memory region, so `. = 0x1000` moves the dot to 0x43000.

lld handles the dot as an absolute value, so assigning 0x1000 to the dot is
considered to be moving the dot backwards from 0x42004 to 0x1000, causing an
error.

I think there are a few different ways to fix this issue, but I'm not sure what
is the best/easiest way to do that.

# REQUIRES: x86
# RUN: echo '.section .foo,"a"; .quad 1; .section .bar,"a"; .quad 1' \
# RUN:   | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
# RUN: ld.bfdx -o %t.so --script %s %t.o
# RUN: llvm-readobj -symbols %t.so | FileCheck %s

# CHECK: 0000000000042000         .baz   00000000 foo
# CHECK: 0000000000043000         .baz   00000000 bar

MEMORY {
  rom : ORIGIN = 0x42000, LENGTH = 0x100000
}

SECTIONS {
  .baz : {
    foo = .;
    *(.foo)
    . = 0x1000;
    bar = .;
    *(.bar)
  } > rom
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190822/1b45077d/attachment.html>


More information about the llvm-bugs mailing list