Skip to content

[RISCV] Incomplete llvm-objdump disassembly when using LTO #76231

Open
@andcarminati

Description

@andcarminati

I detected the following problem related to LTO. Considering the following use case:

A simple C program :

int __attribute__((used)) main(){
}

If we build it with:

clang  --target=riscv32 -march=rv32imafdc -mabi=ilp32d  -O1 sample.c -o sample.elf 

We get with llvm-objdump:

Disassembly of section .text:

000110d4 <main>:
   110d4: 01 45         li      a0, 0
   110d6: 82 80         ret

But, if we build it with:

clang  --target=riscv32 -march=rv32imafdc -mabi=ilp32d  -O1 sample.c -o sample.elf -flto

Then we have:

Disassembly of section .text:

000110d4 <main>:
   110d4: 01 45         <unknown>
   110d6: 82 80         <unknown>

It seems that it is related to the ELF attributes, under LTO they became incomplete in the final elf. The disassembler cannot decode because the feature flags are not present in the MCSubtarget.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions