summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibELF
AgeCommit message (Collapse)Author
2023-05-05Userland: Fix wrong signature of `dladdr`Fabian Dellwing
This function is supposed to take a `const void *addr` as first parameter, but we took a `void *addr`. https://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/baselib-dladdr-3.html
2023-04-30LibELF: Report file path for unimplemented `DYNAMIC` tagsJelle Raaijmakers
This allows us to immediately locate the shared library with the unimplemented tag.
2023-04-23LibELF: Add AArch64 PLT trampolineDaniel Bertalan
This is used for lazy symbol binding, which is used by e.g. ports that are not linked with `-z now`.
2023-04-14Everywhere: Use ARCH(AARCH64) instead of AK_ARCH_AARCH64Nico Weber
The former is typo-resistant after 349e54d5375a4a, so make use of that.
2023-04-11LibELF: Remove leftover i386 entry filesTim Schumacher
2023-04-09DynamicLoader: Remove the unused load_regions vectorIdan Horowitz
2023-03-06Everywhere: Remove NonnullRefPtr.h includesAndreas Kling
2023-03-06Everywhere: Stop using NonnullRefPtrVectorAndreas Kling
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-02-24Kernel+Userland: Refine preventing syscall annotations of Regions optionLiav A
Instead of using a special case of the annotate_mapping syscall, let's introduce a new prctl option to disallow further annotations of Regions as new syscall Region(s).
2023-02-15LibELF: Implement _invoke_entry for aarch64Timon Kruiper
2023-02-15LibELF+LibC: Add support for aarch64 relocationsTimon Kruiper
This commit adds the used relocation types to elf.h, and handles the types in DynamicLoader and DynamicObject. No new functionalitty has to be added, as the same code can be reused between aarch64 and x86_64.
2023-02-15LibELF+LibC: Add support for relative relocations in aarch64 binariesTimon Kruiper
This commit adds R_AARCH64_RELATIVE to elf.h and uses it in ELF::perform_relative_relocations to correctly verify the relocation type. This is the only change needed to support relative relocations for aarch64.
2023-02-08LibELF: Add EM_AARCH64 as expected architecture for ELF validationTimon Kruiper
2023-01-27LibElf: Remove declarations for non-existent methodsSam Atkins
2023-01-21Kernel+Libraries: Don't include limits.h from LibELF/Validation.hAndrew Kaster
The fallout of this is that Kernel/Syscalls/execve.cpp doesn't have access to ARG_MAX anymore, so move that definition to Kernel/API as well
2023-01-21Kernel+Libraries: Move defines and types from sys/auxv.h to Kernel/APIAndrew Kaster
And don't include <sys/auxv.h> from LibELF/AuxiliaryVector.h, to reduce the number of Kernel files that include LibC headers.
2023-01-21Everywhere: Remove string.h include from AK/Traits.h and resolve falloutAndrew Kaster
A lot of places were relying on AK/Traits.h to give it strnlen, memcmp, memcpy and other related declarations. In the quest to remove inclusion of LibC headers from Kernel files, deal with all the fallout of this included-everywhere header including less things.
2023-01-02Everywhere: Remove unused includes of AK/Memory.hBen Wiederhake
These instances were detected by searching for files that include AK/Memory.h, but don't match the regex: \\b(fast_u32_copy|fast_u32_fill|secure_zero|timing_safe_compare)\\b This regex is pessimistic, so there might be more files that don't actually use any memory function. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/Concepts.hBen Wiederhake
These instances were detected by searching for files that include AK/Concepts.h, but don't match the regex: \\b(AnyString|Arithmetic|ArrayLike|DerivedFrom|Enum|FallibleFunction|Flo atingPoint|Fundamental|HashCompatible|Indexable|Integral|IterableContain er|IteratorFunction|IteratorPairWith|OneOf|OneOfIgnoringCV|SameAs|Signed |SpecializationOf|Unsigned|VoidFunction)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any concepts. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Move AK/Debug.h include to using files or removeBen Wiederhake
2022-12-31LibELF: Export static resolve_library method of the DynamicLinker codeLiav A
It will be used in the following commit to introduce a new utility to use this method.
2022-12-31LibELF: Warn if resolving a library resulted in a relative pathTim Schumacher
2022-12-28LibELF+LibSymbolication: Remove i686 supportLiav A
2022-12-28Kernel+Userland: Remove dependency on i386-specific registersLiav A
2022-12-20LibELF: Include <pthread.h> to ensure PTHREAD_STACK_MAX is availableAndrew Kaster
Android's bionic C library puts this definition in pthread.h rather than limits.h
2022-12-16DynamicLoader: Annotate all loaded library ranges as immutableLiav A
To further protect all virtual memory regions of the loaded libraries, don't allow to mutate these regions both in changing their annotations nor the protection bits.
2022-12-16Kernel: Reintroduce the msyscall syscall as the annotate_mapping syscallLiav A
This syscall will be used later on to ensure we can declare virtual memory mappings as immutable (which means that the underlying Region is basically immutable for both future annotations or changing the protection bits of it).
2022-12-11Kernel+LibC+LibELF: Set stack size based on PT_GNU_STACK during execvesin-ack
Some programs explicitly ask for a different initial stack size than what the OS provides. This is implemented in ELF by having a PT_GNU_STACK header which has its p_memsz set to the amount that the program requires. This commit implements this policy by reading the p_memsz of the header and setting the main thread stack size to that. ELF::Image::validate_program_headers ensures that the size attribute is a reasonable value.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-29LibELF: Add stack guard hardeningKeegan Saunders
Employ the same hardening that glibc and the Linux kernel use for generating stack guards: zero the first byte of the guard such that if C-style string functions read out of bounds on the stack, we do not overwrite or potentially leak the stack guard.
2022-11-29LibC: Use uintptr_t for __stack_chk_guardKeegan Saunders
We used size_t, which is a type that is guarenteed to be large enough to hold an array index, but uintptr_t is designed to be used to hold pointer values, which is the case of stack guards.
2022-10-31LibELF: Drop the "resolve and map" all-in-oneTim Schumacher
Both users of this function now have to do their resolving separately before anyways, so let's just drop the resolving part inside the function and require absolute paths to be fed in instead.
2022-10-31LibELF: Track libraries using their full pathTim Schumacher
2022-10-31LibELF: Handle absolute and relative paths for all resolve requestsTim Schumacher
2022-10-31LibELF: Sift down "library name only"-strings as far as possibleTim Schumacher
I might have gone a bit overboard with the `VERIFY`s, but this allows for very easy tracking of where we start to leak in non-absolute paths.
2022-10-31LibELF: Use a bit of `TRY` in `DynamicLinker`Tim Schumacher
`TRY` also works for `Result<>`. Who knew?
2022-10-31LibELF: Prepend `resolve_and` to one of the `map_library` overloadsTim Schumacher
Having two functions that are named the same and whose behavior regarding "should probably get a full path" and "does explicitly not require a full path" is quite confusing, especially since that difference is dictated through the other passed arguments.
2022-10-31LibELF: Drop the separate file name member from DynamicLoaderTim Schumacher
2022-10-31LibELF: Ensure that DynamicLoader only receives absolute pathsTim Schumacher
While at it, start renaming variables where we know that they store a path, so that we will get less confused in the future.
2022-10-14AK+Userland: Stub out code that isn't currently implemented on AARCH64Gunnar Beutner
Even though this almost certainly wouldn't run properly even if we had a working kernel for AARCH64 this at least lets us build all the userland binaries.
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-05LibC: Move `dlfcn_integration.h` to the `bits` directoryTim Schumacher
2022-09-05Everywhere: Refer to `dlfcn*.h` by its non-prefixed nameTim Schumacher
2022-07-21Utilities+LibELF: Temporary promises for dynamic linker in "pledge"Itamar
This adds a "temporary promises for the dynamic-linker" flag ('-d') to the "pledge" utility. Example usage: pledge -d -p "stdio rpath" id Without the '-d' flag, id would crash because the dynamic linker requires 'prot_exec'. When this flag is used and the program to be run is dynamically linked, "pledge" adds promises that are required by the dynamic linker to the promise set provided by the user. The dynamic linker will later "give up" the pledge promises it no longer requires.
2022-07-20LibELF: Copy the entire TLS segment instead of each symbol one-by-oneTim Schumacher
This automatically fixes an issue where we were accidentally copying garbage data from beyond the TLS segment as uninitialized data isn't actually stored inside the image.
2022-07-20LibELF: Remove outdated TLS handling in generic program header codeTim Schumacher
2022-07-19LibC: Remove a bunch of weak `pthread_*` symbolsTim Schumacher
2022-07-12Everywhere: Use default StringView constructor over nullptrsin-ack
While null StringViews are just as bad, these prevent the removal of StringView(char const*) as that constructor accepts a nullptr. No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.