[llvm-bugs] [Bug 32816] New: link order not working well with linker scripts

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 26 12:42:04 PDT 2017


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

            Bug ID: 32816
           Summary: link order not working well with linker scripts
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: rafael.espindola at gmail.com
                CC: llvm-bugs at lists.llvm.org

Given the linker script

SECTIONS {
.text : { *(.text.bar) *(.text.foo)  }
}

and the input

.global _start
_start:
        .section .text.bar,"a", at progbits                                       
                                                                               
                            .quad 2
        .section .text.foo,"a", at progbits
        .quad 1
        .section .rodata.foo,"ao", at progbits,.text.foo
        .quad 1
        .section .rodata.bar,"ao", at progbits,.text.bar
        .quad 2

We produce

Hex dump of section '.text':
  0x00000000 02000000 00000000 01000000 00000000 ................

Hex dump of section '.rodata':
  0x00000010 01000000 00000000 02000000 00000000 ................

The problem is that we sort the input sections in finalize, but do nothing to
the script that actually computes the offset.

I think the solution is similar to what has been discussed for thunks: use a
dummy script when one is not provided.

-- 
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/20170426/db42ab55/attachment.html>


More information about the llvm-bugs mailing list