-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvm-strip throws invalid relocation offset when using --strip-debug #22291
Comments
I can confirm that running
|
This same crash happens when stripping the object file first and then trying to add it to an archive. This suggests that the stripping is corrupting the object file in such a way that it crashes the object file parser. |
Actually looking at the file, the debug sections are gone, but the reloc sections that point to them are still there. Maybe the problem is that the linking section parser is finding the symbols pointing to the sections that are gone, and asserting, rather than handling this error in a more reasonable way. More generally we should probably be resilient to bogus symbols and relocations. And probably we should also strip relocations that point to debug sections when stripping only debug info. |
@dschuff It makes sense now, is there any workaround like option of removing the reloc sections of the debug sections that are stripped off?. |
Unfortunately it doesn't look like it. Even if you remove the relocation sections, it looks like it's the invalid symbols in the symbol table (that point into the stripped debug info section) that are causing the problem. Having said that though, as @kripken said in #22289 the expected way to do stripping is to link first, and then strip the wasm file after linking. That would avoid this problem and still let you have both a debuggable and smaller binary to work with. Thinking about what the "right" behavior should be here: clearly the object file parser should not crash when reading corrupted symbol tables if possible. But the symbol table is still "invalid" because there are symbols pointing into nonexistent sections. And stripping out sections should probably (?) not also modify the symbol table. So what should the linker do if it encounters Is there a particular reason you need to be able to strip the object/library files instead of the linked wasm file? |
@dschuff Our use case is little different, we build WASM by linking a set of static libraries. For the ease of local development, we want to have a choice of which libraries to consider including the debug symbols for. For unwanted libraries, we want to strip the debug symbols first and then build WASM along with a dedicated dwarf symbol file with debug info only from the required libraries. |
I opened llvm/llvm-project#102002 on the LLVM side. Sadly it looks like it might be fair amount of work to result this. |
Thanks @sbc100 . |
@sbc100 I see that fix is merged on the Any timeline on the fix to be picked up by the emscripten?. |
The fix should be in 3.1.65 which was released yesterday. |
Closing this issue for now, please re-open if it persists. |
Discussed in #22289
Originally posted by gmarella July 28, 2024
Hi,
I am trying to use
llvm-strip
that gets shipped with emscripten to strip the debug information from the static library compiled usingemcc
. It always throws the errorinvalid relocation offset
when the strip command is executed. This looked basic when we started but not able to get it working. Any inputs?I also tried removing the debug section from the
simple_thread.o
first and then creating the archive but hit the same error during archive creation step.Code structure is as follows (Gist is also at https://gist.github.com/gmarella/9caa8a88fdd221c1fed4062e5a81c782 )
Libary code
simple_thread.cpp
simple_thread.h
main.cpp
Makefile
The text was updated successfully, but these errors were encountered: