-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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-objcopy] Don't remove .gnu_debuglink section when using --strip-all #78919
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-binary-utilities Author: Felix Kellenbenz (felixkellenbenz) ChangesThis fixes #57407 and therefore makes Full diff: https://github.com/llvm/llvm-project/pull/78919.diff 1 Files Affected:
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index daf03810fd7bff..b6d77d17bae36c 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -450,6 +450,8 @@ static Error replaceAndRemoveSections(const CommonConfig &Config,
return false;
if (StringRef(Sec.Name).starts_with(".gnu.warning"))
return false;
+ if (StringRef(Sec.Name).starts_with(".gnu_debuglink"))
+ return false;
// We keep the .ARM.attribute section to maintain compatibility
// with Debian derived distributions. This is a bug in their
// patchset as documented here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the contribution.
Please could you add a new lit test case to show that this behaviour works as intended.
I note that this code as-is only impacts --strip-all
behaviour. This means that if you use --strip-debug
, the section will get removed. Is this intentional? What do GNU strip or objcopy do in these cases?
Hey thanks for the review, I will add a test case in a moment. That's true, my change only impacts Here are the commands I used when testing the
EDIT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change looks good to me. Before this can be merged, please tweak your PR title and description slightly, as this is used for the final commt message that is merged into main:
- Add [llvm-objcopy] to the title line (llvm-strip is basically just an alias of llvm-objcopy with some slightly different command-line options and we tend to use the llvm-objcopy tag more often than llvm-strip).
- The title should mention --strip-all, so something like
[llvm-objcopy] Don't remove .gnu_debuglink section with --strip-all
- In the description, make sure you're using the actual links to the issue, rather than the GitHub shorthand of #NNNNNN: this is because if somebody is looking at the git log on the command-line, #NNNNNN isn't a useful link.
- In the description, mention llvm-objcopy as well as llvm-strip and --strip-all (e.g. "and therefore makes llvm-strip (and llvm-objcopy) not remove the .gnu_debuglink section when used with --strip-all"). Note that --strip-all is on by default for llvm-strip, but not llvm-objcopy, hence why the behaviour works as it does.
When you've made those changes, ping me and I'll merge the patch for you.
(FWIW, as a minor issue, I disagree with (3) "In the description, make sure you're using the actual links to the issue, rather than the GitHub shorthand of #NNNNNN: this is because if somebody is looking at the git log on the command-line, #NNNNNN isn't a useful link." - before github we used "PRNNNN" in bugs, not generally full links to bugs.llvm.org, and I think by-and-large we probably have way more #NNNNN than full links to github issues these days (github certainly encourages it by linking them, etc) so for consistency I think we should probably go with that - or at least I wouldn't actively discourage it (& I probably wouldn't actively discourage someone who put a full link in either, to be fair - but I guess I'm actively discouraging the active discouraging of #NNNN at least... if that makes any sense)) |
@jh7370 I made the requested changes. I replaced the #NNNNN with a link but it seems link git hub automatically converts it to #NNNNN. |
@felixkellenbenz, I've gone ahead and merged this. Please keep an eye out for test failure emails from the CI build bots that look like they might be to do with your change (note that you may get some failure emails that have nothing to do with your change - you can safely ignore those ones). |
Also, please resolve the issue when you are ready. |
This commit has an author field of https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it/74223 I have run |
This fixes the issue mentioned here: #57407
It prevents
llvm-objcopy
from removing the.gnu _debuglink
section when used with the--strip-all
flag. Since--strip-all
is the default ofllvm-strip
the patch also preventsllvm-strip
from removing the.gnu_debuglink
section.