Skip to content

Strip symbols of all binaries#109

Merged
sunfishcode merged 1 commit into
WebAssembly:masterfrom
abrown:strip-all-binaries
Apr 3, 2020
Merged

Strip symbols of all binaries#109
sunfishcode merged 1 commit into
WebAssembly:masterfrom
abrown:strip-all-binaries

Conversation

@abrown

@abrown abrown commented Mar 24, 2020

Copy link
Copy Markdown
Collaborator

@sbc100, this resolves the discussion we had in #108 about stripping symbols from all binaries.

Comment thread Makefile Outdated
@abrown abrown force-pushed the strip-all-binaries branch from 3141caa to 6dbd13e Compare March 25, 2020 19:30
@abrown abrown changed the title Strip symbols of all binaries generated in /bin Strip symbols of all binaries Mar 25, 2020
@sunfishcode

Copy link
Copy Markdown
Member

Testing for "ELF" is too narrow since we also support on-ELF hosts such as macOS. Would it work to just unconditionally run strip on every file under bin and ignore errors?

Alternatively, if we could add "-s" to the link command-line, that would cause it to strip executables too.

@abrown abrown force-pushed the strip-all-binaries branch from 6dbd13e to 25b4e3e Compare March 30, 2020 23:06
@abrown

abrown commented Mar 30, 2020

Copy link
Copy Markdown
Collaborator Author

@sunfishcode, I didn't really know all the places -s might be needed so I tried the "strip everything and ignore errors" approach. Note that due to the discussion above with @sbc100 (resolved now) we are stripping everything, not just the bin directory.

@sbc100

sbc100 commented Mar 30, 2020

Copy link
Copy Markdown
Member

I think post-stripping is probably best.

The current approach of this patch is to strip anything that find things is executable. Seems reasonable to me that we just stick with that approach. Dan?

@sunfishcode

Copy link
Copy Markdown
Member

Sounds reasonable.

@sunfishcode sunfishcode merged commit f754491 into WebAssembly:master Apr 3, 2020
kildom pushed a commit to kildom/clang-wasi-port that referenced this pull request Jul 14, 2021
…s. (WebAssembly#109)

* Link `populate_environ` only if we actually need environment variables.

This avoids linking in the environment variable initialization code,
and the __wasi_environ_sizes_get and __wasi_environ_get imports, in
programs that don't use environment variables.

This also removes the "___environ" (three underscores) alias symbol,
which is only in musl for backwards compatibility.

* Switch to //-style comments.

* If malloc fails, don't leave `__environ` pointing to an uninitialized buffer.

* Fix a memory leak if one malloc succeeds and the other fails.

* Use calloc to handle multiplication overflow.

This also handles the NULL terminator.

* Don't initialize __environ until everything has succeeded.

* Avoid leaking in case __wasi_environ_get fails.

* Handle overflow in the add too.

* Add #include <stdlib.h> for malloc etc.

* If the environment is empty, don't allocate any memory.
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.

3 participants