Commit Graph

35 Commits

Author SHA1 Message Date
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
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.
2022-07-12 23:11:35 +02:00
sin-ack
60f6bc902b Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc
functions which expect null-terminated strings, so String objects were
used there instead.
2022-07-12 23:11:35 +02:00
Tim Schumacher
89da0f2da5 LibELF: Name library maps with the full file path 2022-05-07 20:02:00 +02:00
Andrew Kaster
9b041786ac readelf: Don't error out on invalid interpreter path
This lets us inspect ELF binaries with un-loadable program interpreters,
same as binutils and llvm-readelf.
2022-05-02 01:45:49 +02:00
Daniel Bertalan
484f70fb43 readelf: Add printing for STT_GNU_IFUNC 2022-05-01 12:42:01 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Brian Gianforcaro
0a9e84aff0 readelf: Port to LibMain 2022-03-22 11:39:20 +01:00
Daniel Bertalan
10c629055f Utilities/readelf: Add printing for RELR relocations 2022-02-11 18:07:53 +01:00
Daniel Bertalan
b509d8a2f7 Utilities/readelf: Add support for printing the content of sections 2022-01-24 10:41:47 +00:00
Thijs Waalen
6210f62b1d readelf: Fall back to default interpreter path on empty path
This fixes readelf failing to map the interpreter for dynamic
libraries. When an ELF does not have the PT_INTERP header the
StringView will be of the inline capacity of the StringBuilder, not a
null StringView. This would cause readelf not to fallback on the
default interpreter path.
2022-01-16 22:36:06 -08:00
Idan Horowitz
cfb9f889ac LibELF: Accept Span instead of Pointer+Size in validate_program_headers 2022-01-13 22:40:25 +01:00
Idan Horowitz
3e959618c3 LibELF: Use StringBuilders instead of Strings for the interpreter path
This is required for the Kernel's usage of LibELF, since Strings do not
expose allocation failure.
2022-01-13 22:40:25 +01:00
Andreas Kling
58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Valtteri Koskivuori
d1adf5bc5e LibELF+Userland: Move a few functions to Elf::Image
These were originally in `readelf`, but they became useful in
`file` as well, so they are now available in Elf::Image with a slightly
revised API.
2021-10-21 01:14:09 +02:00
Rodrigo Tobar
3efd7b458a LibELF+readelf: Remove duplicated dtag->string map
A copy of the same mapping was found both in LibELF and in the readelf
utility, which uses LibELF; keeping them both is redundant and removing
the duplicate saves (a bit of) space.
2021-09-26 12:45:55 +02:00
Rodrigo Tobar
73e42917f9 Utilities: Show dynamic ELF info with "show all" option 2021-09-11 15:37:38 +03:00
Gunnar Beutner
0e0985f15c Utilities: Make the columns for readelf fit all reloc types on x86_64 2021-07-22 08:57:01 +02:00
Gunnar Beutner
db1c5c4830 LibELF+Utilities: Avoid truncating 64-bit values
This fixes displaying 64-bit addresses in readelf and also fixes
showing backtraces from core dumps on x86_64.
2021-07-22 08:57:01 +02:00
Gunnar Beutner
36c3927169 Utilities: Make sure columns are properly aligned for readelf on x86_64 2021-07-22 08:57:01 +02:00
Gunnar Beutner
31f30e732a Everywhere: Prefix hexadecimal numbers with 0x
Depending on the values it might be difficult to figure out whether a
value is decimal or hexadecimal. So let's make this more obvious. Also
this allows copying and pasting those numbers into GNOME calculator and
probably also other apps which auto-detect the base.
2021-07-22 08:57:01 +02:00
Gunnar Beutner
3ed29895e4 readelf: Add names for x86_64 relocations and machine type 2021-07-18 17:31:13 +02:00
Gunnar Beutner
158355e0d7 Kernel+LibELF: Add support for validating and loading ELF64 executables 2021-06-28 22:29:28 +02:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Nicholas Baron
aa4d41fe2c
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best
fitting one. All this will require is duplicating the implementation and
simplifying for the `void` case.

This constraining also informs both the caller and compiler by passing
the callback parameter types as part of the constraint
(e.g.: `IterationFunction<int>`).

Some `for_each` functions in LibELF only take functions which return
`void`. This is a minimal correctness check, as it removes one way for a
function to incompletely do something.

There seems to be a possible idiom where inside a lambda, a `return;` is
the same as `continue;` in a for-loop.
2021-05-16 10:36:52 +01:00
Gunnar Beutner
f40ee1b03f LibC+LibELF: Implement more fully-features dlfcn functionality
This implements more of the dlfcn functionality. Most notably:

* It's now possible to dlopen() libraries which were already
  loaded at program startup time. This does not cause those
  libraries to be loaded twice.
* Errors are reported via dlerror() rather than by crashing
  the program.
* Calls to the dl*() functions are thread-safe.
2021-04-25 10:14:50 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
46209ee9d0 readelf: Remove an unnecessary String::format() 2021-04-21 23:49:02 +02:00
Gunnar Beutner
8ca5b8c065 LibC: Move S_* defines into <fcntl.h>
According to the Single UNIX Specification, Version 2 that's where
those macros should be defined. This fixes the libiconv port.

This also fixes some (but not all) build errors for the diffutils and nano ports.
2021-04-11 09:51:20 +02:00
Idan Horowitz
eab151c994 LibElf+readelf: Parse ELFs with no program headers correctly
This simply fixes a check which assumed the program header count was
always non zero.
2021-03-29 19:57:19 +02:00
Brendan Coles
677e5e4d84 readelf: Use Loader.so interpreter for dynamic section and symbols 2021-03-22 17:46:05 +01:00
Brendan Coles
ed1789cc04 readelf: Add --checksec flag to display security hardening info 2021-03-19 09:17:17 +01:00
Brendan Coles
81cbb2676e readelf: Tweak section headers output column padding 2021-03-14 21:36:54 +01:00
Brendan Coles
6bc01909b7 readelf: Add support for core notes and relocations 2021-03-14 13:55:07 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00