[llvm-bugs] [Bug 42990] New: assignments made before SECTIONS do not reflect final values after section parsing

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 13 15:12:24 PDT 2019


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

            Bug ID: 42990
           Summary: assignments made before SECTIONS do not reflect final
                    values after section parsing
           Product: lld
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: keescook at chromium.org
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

The following poc.lds links differently between bfd and lld:


__efistub__end = _end;
SECTIONS
{
 . = 0xffff;
 . += ((_end >> 8) - 0xff );
 _end = .;
}

Linking with an empty .o file:

$ ld.lld -maarch64elf -shared -o vmlinux.lld -T poc.lds  /tmp/test.o && readelf
-Ws vmlinux.lld | egrep '\b(__init_pg_size|(__efistub_|)_end)\b'
     2: 000000000000ffff     0 NOTYPE  GLOBAL DEFAULT    1 _end
     3: 000000000000ff00     0 NOTYPE  GLOBAL DEFAULT    1 __efistub__end

i.e. __efistub__end is calculated before _end is known. Moving the
__efistub__end assignment to after the SECTIONS {} works around this bug.

bfd produces the same results with either ordering:

$ aarch64-linux-gnu-ld.bfd -maarch64elf -shared -o vmlinux.bfd -T poc.lds 
/tmp/test.o && readelf -Ws vmlinux.bfd | egrep
'\b(__init_pg_size|(__efistub_|)_end)\b'
     2: 000000000000ffff     0 NOTYPE  GLOBAL DEFAULT    1 _end
     4: 000000000000ffff     0 NOTYPE  GLOBAL DEFAULT  ABS __efistub__end

-- 
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/20190813/218615b1/attachment.html>


More information about the llvm-bugs mailing list