Closed liutao-liu closed 8 months ago
gimli definitely can parse multiple units, so you'll need to give more information on how to reproduce the problem you are seeing.
Can you provide an example file?
My running environment: aarch64 + ubuntu 20.04 TSL Gimli version:0.28.1
The example in simple_line.rs attempt to parse all units in an object file. Then i run the example in simple_line.rs to parse my object. This object has two units, but simple_line.rs can only parse the first unit, as shown in the following figure.
My a.out comes out like this: test1.c
int func(){
return 10;
}
test2.c
int main(int argc, char** argv)
{
int ret = 1;
return ret;
}
Compiling test1.c and test2.c using clang-16:
./clang+llvm-16.0.0-aarch64-linux-gnu/bin/clang -c -gdwarf-4 -emit-llvm test1.c -S -o test1.ll
./clang+llvm-16.0.0-aarch64-linux-gnu/bin/clang -c -gdwarf-4 -emit-llvm test2.c -S -o test2.ll
./clang+llvm-16.0.0-aarch64-linux-gnu/bin/llvm-link -o test.ll test1.ll test2.ll
./clang+llvm-16.0.0-aarch64-linux-gnu/bin/clang test.ll -c -o a.out
Please attach the binary a.out
so that I can reproduce the issue.
Sorry, I can't offer a.out. The example I've given is simple, and you can compile it very quickly by following the steps above. The problem can also be reproduced in the x86 environment.
It's simple to add the file to this issue, but okay, I'll have to wait until next week to look at it then.
It's simple to add the file to this issue, but okay, I'll have to wait until next week to look at it then.
I don't have permission to upload files.
The problem is that you are building a relocatable object file, and the simple_line
example does not process relocations, so various references in the DWARF are read as zeroes. If you build an executable then it works fine: clang test.ll -o a.out
Alternatively, the dwarfdump
example does process relocations.
As shown in the following figure, when there are multiple units, Gimli parses only the first unit from the ELF file.