When .gnu.version_r is empty (allowed by readelf but warned by objdump),
llvm-objdump -p may decode the next section as .gnu.version_r and may crash due
to out-of-bounds C string reference. ELFFile<ELFT>::getVersionDependencies
handles 0-entry .gnu.version_r gracefully. Just use it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/Object/ELF.h | ||
---|---|---|
1041 | Should this be a separate patch? | |
llvm/test/tools/llvm-objdump/ELF/verneed-invalid.test | ||
2 | Similarly, this test seems unrelated to the commit message? | |
llvm/tools/llvm-objdump/ELFDump.cpp | ||
301–306 | Nit: this local variable seems a little bit unnecessary? | |
352–356 | These variables are only used in the else part now. Could we move them? |
llvm/include/llvm/Object/ELF.h | ||
---|---|---|
1041 | Without this change llvm-objdump -p output may contain \0 separated strings, which are incorrect. The only other use llvm/tools/llvm-readobj/ELFDumper.cpp:4706 avoids the problem by using VN.File.data(). | |
llvm/test/tools/llvm-objdump/ELF/verneed-invalid.test | ||
2 | I need a file to test reportWarning(toString(V.takeError()), FileName); The change is like rewriting an existing functionality. Personally I think the needed tests should be like as if we do not have the functionality yet. | |
llvm/tools/llvm-objdump/ELFDump.cpp | ||
301–306 | It avoids repeated outs() call at the cost of one extra line. I think it is worthwhile. | |
352–356 | They can but they aren't so related to this change. We can rewrite printSymbolVersionDefinition to use the llvm/lib/Object API as well then these variables can go away with that change. |
The patch looks good to me. I have tested it in yocto world builds, it fixes the problem and there are no new regressions.
Looks good, thanks!
llvm/test/tools/llvm-objdump/ELF/verneed-invalid.test | ||
---|---|---|
2 |
Agreed. If anything, I'd have added this as a prerequisite patch, but it's fine as-is. Thanks! | |
llvm/tools/llvm-objdump/ELFDump.cpp | ||
352–356 | Sounds reasonable. |
Should this be a separate patch?