Skip to content

Remove "--hash-style=both" #999

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

Merged
merged 1 commit into from
Apr 17, 2020
Merged

Conversation

tianon
Copy link
Member

@tianon tianon commented Apr 17, 2020

It turns out that --hash-style=gnu is considered better than either of --hash-style=both or --hash-style=sysv, assuming your environment/platform supports it.

On amd64 with both Debian's and Alpine's linkers, --hash-style=gnu is the default.

This is especially relevant on MIPS (mips64le), where ld: .gnu.hash is incompatible with the MIPS ABI (so the linker sanely defaults to --hash-style=sysv there, as it should).

Refs #272

@tianon
Copy link
Member Author

tianon commented Apr 17, 2020

Forgot to include the pudding. 😅

Current: (--hash-style=both)

$ docker run --rm php:7.4-alpine sh -c 'apk add --no-cache binutils && readelf --headers /usr/local/bin/php' | grep '[.]hash'
  [ 2] .hash             HASH             0000000000000290  00000290
  [ 3] .gnu.hash         GNU_HASH         00000000000046e0  000046e0
   02     .interp .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt 

This PR on amd64 (both Debian and Alpine builds):

$ docker run --rm 60ccb5f28a3c readelf --headers /usr/local/bin/php | grep '[.]hash'
  [ 4] .gnu.hash         GNU_HASH         0000000000000308  00000308
   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt 

$ docker run --rm c22cf30dded9 sh -c 'apk add --no-cache binutils && readelf --headers /usr/local/bin/php' | grep '[.]hash'
  [ 2] .gnu.hash         GNU_HASH         0000000000000290  00000290
   02     .interp .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt 

This PR on mips64le:

$ docker run --rm c138082f66eb readelf --headers /usr/local/bin/php | grep '[.]hash'
  [ 5] .hash             HASH             0000000000004cb8  00004cb8
   03     .MIPS.abiflags .MIPS.options .note.gnu.build-id .dynamic .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .init .text .MIPS.stubs .fini .rodata .interp .eh_frame .note.ABI-tag 

@tianon
Copy link
Member Author

tianon commented Apr 17, 2020

FWIW, https://flameeyes.blog/2010/09/09/are-we-done-with-ldflags/ has a pretty good discussion of the history behind the two options -- mostly, the reason to use both is so that your final binaries can be used on older userspace implementations than the one you've compiled in, which is definitely not a goal of this image (it's expected that you're compiling things to use within the same variant of the image).

It turns out that --hash-style=gnu is considered better than either of --hash-style=both or --hash-style=sysv, assuming your environment/platform supports it.

On amd64 with both Debian's and Alpine's linkers, --hash-style=gnu is the default.

This is especially relevant on MIPS (mips64le), where "ld: .gnu.hash is incompatible with the MIPS ABI" (so the linker sanely defaults to --hash-style=sysv there, as it should).
@tianon tianon merged commit 94ed60e into docker-library:master Apr 17, 2020
@tianon tianon deleted the hash-style branch April 17, 2020 05:07
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Apr 17, 2020
Changes:

- docker-library/php@94ed60e: Merge pull request docker-library/php#999 from infosiftr/hash-style
- docker-library/php@7ccfc92: Remove "--hash-style=both"
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.

2 participants