Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
|
|
Clean up everything and add lots of new functions
I hope everything here is okay. I fixed some bugs in existing functions (mostly wrong prototypes or off-by-one errors) and formatted everything to a consistent style. If you'd like me to adjust the style, that's no problem. It wasn't very consistent to start with (within the code, and compared to the documentation).
*I added specific notes you may want to comment on to some of the commit messages.*
Major features:
* Pass correct `argv[0]` in loader
* Intercept `readlink("/proc/self/exe")` to allow re-exec
* Add almost all reasonable-to-implement functions in LSB 5.0.0 core generic libc. Remaining functions are:
- Impossible-to-implement: sigreturn
- Not useful: reentrant random (`*rand48_r`, etc.), argz, envz, pmap, rpc (clnt_*, svc*, xdr*), bindresvport
- Got tired of it: checked wchar
* Add additional functions used by android and its NDK tools (clang, cmake, lldb, ninja, etc.).
At this point, I am able to run Android Studio with the bundled prebuilt JDK, and compile, install, and run an android application (including one with native libraries) on a real device, with only a few minor issues:
* must export `LD_LIBRARY_PATH=/opt/android-studio/jre/jre/lib/amd64/server` because musl and glibc interpret the variable differently with regards to `dlopen`. This is something that has to be patched in musl builds of openjdk, so it's not a gcompat issue.
* ld.bfd fails to parse the argument `--sysroot=/path`, but can parse `--sysroot /path`. So there's some difference with `getopt_long_only` (or getopt in general). May be a bug, may be just an API difference. May be it can be patched up.
* LLDB fails to connect to the android phone for native debugging -- I haven't tried it on glibc yet, so it may not be a gcompat issue at all (may be a phone or the app issue).
I'd be happy to send some documentation later.
See merge request !1
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
This allows programs run through gcompat to fork and re-exec themselves.
It fixes readlink("/proc/self/exe") to return the executable's absolute
path, instead of musl's path.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
This takes advantage of the (lack of a) musl implementation for
simplicity.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
On musl pread and pread64 are the same thing.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
The other unimplemented signal function in LSB is sigreturn, with is not
really implementable.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
These take advantage of the musl implementation for simplicity.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
This follows the exceptionally-detailed functional description in the
manual page.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Document functions and sort by name.
* Explicitly include stddef.h.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Add all checked string functions from LSB, plus those found in use
in other applications. Document those functions from LSB as such.
* Use a consistent structure and paramater names for all functions.
* Fix multiple off-by-one errors.
* Use a less hacky and more optimized rawmemchr.
* Sort functions by name.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Fix prototype of __realpath_chk.
* Add all strto* functions from LSB, plus the ones thata were previously
incorrectly in string.c
The main missing LSB functions are the reentrant random functions, which
should not be used anyway.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Add all (non-wchar) stdio functions from LSB, plus those found in use
in other applications. Document those functions from LSB as such.
* Use a consistent structure and paramater names for all functions.
* flag == 0 means FORTIFY_SOURCE=1, so the implemented checks should be
unconditional.
* Add all possible checks without parsing the format string.
* Move functions from wchar.h to their own appropriately-named file.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Make function pointer static.
* Only initialize function pointer once.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Make comment style consistent with the rest of the project, and remove
outdated header name.
* Remove "static inline" from functions (this is no longer a header).
* Check statp for NULL in res_ninit like in res_nclose.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Like fgetpwent_r/getpwent_r, these require a deep copy of the structure
into the caller-provided buffer. This is nontrivial for the array of
strings member.
getgrent_r is required by LSB.
[NOTE: I'm not too happy with the macro, but it works. Any suggestions?]
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
These functions require a deep copy of the structure into the
caller-provided buffer. Also make sure to store NULL in result on error.
Use the stream to differentiate the two functions and avoid duplication.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Add the missing parameter to __register_atfork.
* Sort and document functions.
__pthread_register_cancel and __pthread_unregister_cancel should be
implemented at some point, or else pthread_cleanup_pop(true) will not
work properly and could cause deadlocks in programs that use it.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Add finite() variants, needed by some applications.
* Add remaining long double variants of existing functions.
* Sort and document existing functions, including where referenced in
the LSB standard.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Changes to existing code:
* Make explicit comparison against NULL.
* Adjust debug message for readability.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
Rename the file to match the header it implements functions from.
Changes to existing code:
* Fix the return value from backtrace (off by one).
* Use __builtin_extract_return_addr as recommended in gcc documentation.
* Document header usage.
* Document where the functions are referenced in the LSB standard.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Handle programs that have a DT_NEEDED entry for glibc's ld.so.
* Handle when LD_PRELOAD is already set.
* Use the --argv0 option to properly set argv[0] in the target program.
* Ensure the the argument list is terminated with a NULL sentinel.
* Document the details of the loader's implementation.
[NOTE: Better commit summary?]
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Remove -DPIC as it is unused (and PIC is always enabled).
* Export the loader name as a macro (this will be used in the future).
* Enable compiler warnings, except the expected ones.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Prefer providing the underscore-prefixed symbol as the strong
definition.
* Do not use a weak alias if the alias is also underscore-prefixed.
* Make libgcompat objects depend on the new header.
[NOTE: I originally took the weak_alias macro from musl's libc.h, but
it's trivial and the same pattern already in use. If desired, I
can add the musl copyright notice.]
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
* Apply clang-format.
* Change all comments to the same style.
* Add braces as dictated by the coding style guidelines.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
The settings here are based on the current code style documentation.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
This duplicates the semicolon at the end of the macro, but it prevents
clang-format from getting confused. This is only temporary until the
macro is updated in a later commit.
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
|
|
On GCC 4.9.4, at least backtrace.c fails to compile because of variable
declaration in a for statement, which requires -std=c99 or -std=c11.
Since we are using ISO C mode instead of a GNU standard, we additionally
must define _BSD_SOURCE to expose Dl_info for the dl code.
|
|
Linux/aarch64 does not define SYS__sysctl. This caused build errors in
Alpine[1] and Void[2].
While I'm in here, fix up headers since we don't need errno or strings.
[1]: https://git.alpinelinux.org/cgit/aports/commit/?id=400a9d40
[2]: https://github.com/voidlinux/void-packages/commit/a7aa924e
|
|
|
|
|
|
|
|
|
|
|
|
__memalign is not necessary as musl already provides it.
|
|
|
|
|
|
Makefile: allow compilation with specified compiler
|
|
|
|
|
|
|
|
|