[llvm-bugs] [Bug 52148] New: [RISC-V] ELF flags discarded when using "ld -b binary"

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 11 19:25:34 PDT 2021


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

            Bug ID: 52148
           Summary: [RISC-V] ELF flags discarded when using "ld -b binary"
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: dc at m-labs.hk
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

Overview/TLDR: The RISC-V version of
https://bugs.llvm.org/show_bug.cgi?id=43368. Background/Usage: Same as the one
described in https://bugs.llvm.org/show_bug.cgi?id=43368. A kernel binary file
is needed to be glued onto a runtime binary, so we can use the generated
_binary_* symbols to move the kernel binary into a pre-specified memory
location.

Reproduce steps:
Practically the same as https://bugs.llvm.org/show_bug.cgi?id=43368, but
several RISC-V specific options are needed to compile the binaries.
e.g. -mabi=ilp32d to specify the usage of RISC-V double precision ABI

1. Compile a binary using RISCV32 target and ILP32D ABI.
e.g. clang -target riscv32-unknown-none-elf -march=rv32g -mabi=ilp32d main.c
-nostdlib -o main.o

When examined using llvm-readelf, the value of "Flags" would be 0x4
(double-float-ABI). 

2. Start off with a binary. Link the binary using -b binary.
e.g. ld.lld -r -m elf32lriscv -b binary main.o -o main

When examined using llvm-readelf, the value of "Flags" would become 0x0.

When linking it with another archive built using ILP32D ABI. LLD will then
complain about linking object with different floating-point ABI.
e.g. ld.lld: error:
cargo/riscv32g-unknown-none-elf/debug/libruntime.a(vectors.o): cannot link
object files with different floating-point ABI

The cause of this issue is probably the following patch.
https://reviews.llvm.org/D71101

While it prevented an assertion error, the flag is always set to 0, which cause
the bug described above.
Unlike the same issue in MIPS, it seems that the ABI cannot be inferred from
emulation directly.
Discussion on adding ABI specific emulations for RISC-V targets:
https://reviews.llvm.org/D95755

-- 
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/20211012/84659f7f/attachment-0001.html>


More information about the llvm-bugs mailing list