Skip to content
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

brp-15: revert stripping if strip outputs to stderr #7

Closed
wants to merge 1 commit into from

Conversation

cyphar
Copy link
Member

@cyphar cyphar commented Nov 12, 2016

GNU strip doesn't return any error code if it doesn't recognise the
archive. This results in us still committing a stripping that may have
gone incorrectly, which is unsafe.

Instead, check that the stripping didn't output any errors and only copy
over the stripped archive if there were no errors.

Fixes: boo#964546
Signed-off-by: Aleksa Sarai asarai@suse.com

GNU strip doesn't return any error code if it doesn't recognise the
archive. This results in us still committing a stripping that may have
gone incorrectly, which is unsafe.

Instead, check that the stripping didn't output any errors and only copy
over the stripped archive if there were no errors.

Fixes: boo#964546
Signed-off-by: Aleksa Sarai <asarai@suse.com>
@dirkmueller
Copy link
Member

Is this behavior of strip intentional? Sounds more like a bug than anything else

@cyphar
Copy link
Member Author

cyphar commented Nov 12, 2016

I don't know if it's intentional, but even if it was not intentional (and they fixed it) we'd still need to implement reverting because strip modifies files directly. The only difference is that we'd change the commit condition to "was the exit code 0".

@cyphar
Copy link
Member Author

cyphar commented Nov 12, 2016

This is also related to golang/go#17890.

chmod u+w "$f" || :
strip -p --discard-locals -R .comment -R .note "$f" || :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe there is actually an error code and it is just ignored with the || :

> echo foo > foo
> strip foo
strip:foo: File format not recognized
> echo $?
1

(the above worked on both current Tumbleweed and old SLE-11-SP3)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked and there isn't an error code.

% cp /usr/lib64/go/pkg/linux_amd64/runtime.a .
% strip runtime.a
strip:runtime.a(__.PKGDEF): Unable to recognise the format of file: File format not recognized
strip:runtime.a(_go_.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(asm.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(asm_amd64.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(duff_amd64.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(memclr_amd64.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(memmove_amd64.o): Unable to recognise the format of file: File format not recognized
strip:runtime.a(rt0_linux_amd64): Unable to recognise the format of file: File format not recognized
strip:runtime.a(sys_linux_amd64): Unable to recognise the format of file: File format not recognized
% echo $?
0

The problem is that strip does recognise the .a archive (so it won't error out because of that) but it will incorrectly modify the archive because it doesn't understand the format.

TBH this looks like a mix of a strip bug (not returning a non-zero error code) but there's also a bug in this repo because we're ignoring errors. Also, note that we have to implement reverting anyway.

Copy link
Member

@Conan-Kudo Conan-Kudo Jan 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange, I could have sworn that strip can recognize .a files from Go code...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can "recognise" them, but it incorrectly strips them (this bug is a bit old so I can't remember the precise details, but the general point is that it breaks __.PKGDEF by slightly changing the contents, which Go really doesn't like). I submitted a patch to Go which would ignore the way that strip messes with .a files, but they rejected it on the basis of "we don't support you using strip on Go binaries, the go compiler has a flag that does stripping for you".

For the past year we've solved this problem by simply disabling stripping for all Go packages, but that's quite fickle (you can't really add a macro to do it -- it needs to be added as a #nodebuginfo comment in the spec file, even if you set the magic BRP_... macro variable).

@dirkmueller
Copy link
Member

please rebase if still needed and reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants