1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00
serenity/Userland/Libraries
Daniel Bertalan 3974cac148 LibELF: Implement support for DT_RELR relative relocations
The DT_RELR relocation is a relatively new relocation encoding designed
to achieve space-efficient relative relocations in PIE programs.

The description of the format is available here:
https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Pi9aSwwABgAJ

It works by using a bitmap to store the offsets which need to be
relocated. Even entries are *address* entries: they contain an address
(relative to the base of the executable) which needs to be relocated.
Subsequent even entries are *bitmap* entries: "1" bits encode offsets
(in word size increments) relative to the last address entry which need
to be relocated.

This is in contrast to the REL/RELA format, where each entry takes up
2/3 machine words. Certain kinds of relocations store useful data in
that space (like the name of the referenced symbol), so not everything
can be encoded in this format. But as position-independent executables
and shared libraries tend to have a lot of relative relocations, a
specialized encoding for them absolutely makes sense.

The authors of the format suggest an overall 5-20% reduction in the file
size of various programs. Due to our extensive use of dynamic linking
and us not stripping debug info, relative relocations don't make up such
a large portion of the binary's size, so the measurements will tend to
skew to the lower side of the spectrum.

The following measurements were made with the x86-64 Clang toolchain:

- The kernel contains 290989 relocations. Enabling RELR decreased its
  size from 30 MiB to 23 MiB.
- LibUnicodeData contains 190262 relocations, almost all of them
  relative. Its file size changed from 17 MiB to 13 MiB.
- /bin/WebContent contains 1300 relocations, 66% of which are relative
  relocations. With RELR, its size changed from 832 KiB to 812 KiB.

This change was inspired by the following blog post:
https://maskray.me/blog/2021-10-31-relative-relocations-and-relr
2022-02-11 18:07:53 +01:00
..
LibArchive LibArchive: Limit all Tar header fields to their buffer length 2021-11-24 19:09:00 +02:00
LibAudio AK: Move integral log2 and exp to IntegerMath.h 2022-02-06 17:52:33 +00:00
LibC LibELF: Implement support for DT_RELR relative relocations 2022-02-11 18:07:53 +01:00
LibCards AK: Convert AK::Format formatting helpers to returning ErrorOr<void> 2021-11-17 00:21:13 +01:00
LibChess Everywhere: Fix -Winconsistent-missing-override warnings from Clang 2021-12-11 13:14:15 -08:00
LibCompress Userland: Remove a bunch of unnecessary Vector imports 2022-01-28 23:40:25 +01:00
LibConfig LibConfig: Rename pledge_domains(String) => pledge_domain(String) 2022-02-11 18:06:39 +01:00
LibCore LibCore: Convert AnonymousBuffer to use System::anon_create 2022-02-10 21:35:17 +01:00
LibCoredump LibCoredump: Add stack frame entry even if there is no object info 2022-02-04 20:03:47 +01:00
LibCpp LibCpp: Add SemanticSyntaxHighlighter 2022-02-09 00:51:31 +01:00
LibCrypt LibCrypt: Link the SHA2 hash implementation into LibCrypt privately 2022-01-08 18:56:29 +01:00
LibCrypto LibCrypto: Do not allow signed big integers to be negative zero 2022-02-06 15:49:54 +00:00
LibDebug LibDebug+LibCoredump: Replace remaining reinterpret_casts and C casts 2022-01-28 22:51:27 +00:00
LibDesktop LibDesktop: Add Launcher::ensure_connection() 2022-01-21 13:44:36 +01:00
LibDeviceTree Libraries: Add LibDeviceTree for manipulating OpenFirmware Device Trees 2021-10-21 19:20:03 -07:00
LibDiff LibDiff: Flush leftover hunks at the end 2022-02-09 00:51:31 +01:00
LibDl LibC+LibDl: Declare functions taking no arguments as taking void 2022-01-08 19:22:00 +01:00
LibDSP Everywhere: Use my new serenityos.org e-mail :^) 2022-01-14 11:54:09 +01:00
LibEDID LibEDID: Use correct paths for LibEDID generated files 2022-01-26 16:37:38 +01:00
LibELF LibELF: Implement support for DT_RELR relative relocations 2022-02-11 18:07:53 +01:00
LibFileSystemAccessClient FileSystemAccessClient: Remove old API returning file descriptors :^) 2022-01-20 10:39:12 +01:00
LibGemini LibCore+Userland: Remove Core::TCPSocket :^) 2022-02-06 17:28:17 +00:00
LibGfx LibGfx: Add more syntax-related ColorRoles 2022-02-09 00:51:31 +01:00
LibGL LibGL: Set rasterizer material state without copying 2022-01-27 20:35:38 +00:00
LibGUI Base+HackStudio: Add or insert missing icons 2022-02-10 10:27:26 +00:00
LibHTTP LibHTTP: Skip the body when response code is 204 2022-02-09 21:23:25 +01:00
LibImageDecoderClient LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer 2022-01-15 13:29:48 +03:30
LibIMAP Userland: Convert TLS::TLSv12 to a Core::Stream::Socket 2022-02-06 13:10:10 +01:00
LibIPC LibCore+LibIPC: Move SystemServerTakeover.{h,cpp} to LibCore 2022-02-06 10:28:19 +01:00
LibJS LibJS: Do not refer to moved-from completions / values 2022-02-10 14:10:34 +00:00
LibKeyboard Kernel: Stop using LibKeyboard's CharacterMap in HIDManagement 2022-01-21 18:25:44 +01:00
LibLine LibLine: Replace call to vfork() with fork() 2022-01-07 11:02:30 +01:00
LibM LibM: Count fractions when exponent < -1 with mantissa == 0 2022-01-02 12:44:31 +03:30
LibMain LibMain: Invoke tzset in LibMain so all apps can have time zone info 2022-01-28 15:13:35 +00:00
LibMarkdown Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
LibPCIDB LibCore+AK: Move MappedFile from AK to LibCore 2021-11-23 11:33:36 +01:00
LibPDF LibPDF: Make Filter::decode() return ErrorOr 2022-01-24 22:36:09 +01:00
LibProtocol Userland: Convert TLS::TLSv12 to a Core::Stream::Socket 2022-02-06 13:10:10 +01:00
LibPthread AK+LibC+LibPthread: Introduce NoAllocationGuard 2022-01-11 00:08:58 +01:00
LibRegex LibRegex: Only skip full instructions when optimizing alternations 2022-02-09 21:02:24 +00:00
LibSanitizer AK+Kernel+LibSanitizer: Store "ubsan-is-deadly" flag as Atomic<bool> 2022-02-03 16:11:26 +01:00
LibSoftGPU LibSoftGPU: Dispatch based on ClipPlane enum at compile-time 2022-02-10 10:33:31 +00:00
LibSQL LibSQL: Return unimplemented errors from unimplemented MATCH expressions 2022-02-10 23:11:13 +01:00
LibSymbolication LibCore+AK: Move MappedFile from AK to LibCore 2021-11-23 11:33:36 +01:00
LibSyntax LibCpp: Add SemanticSyntaxHighlighter 2022-02-09 00:51:31 +01:00
LibSystem LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore 2021-11-23 11:33:36 +01:00
LibTest LibWeb: Introduce the Environment Settings Object 2022-02-08 17:47:44 +00:00
LibTextCodec LibTextCodec: Do not allocate the various decoders 2022-01-28 23:31:00 +01:00
LibThreading LibThreading: Invoke BackgroundAction completions on origin event loop 2022-01-25 09:13:40 +01:00
LibTimeZone LibTimeZone: Parse and generate time zone coordinate data 2022-02-03 16:11:15 +01:00
LibTLS LibTLS+RequestServer: Add an option to dump TLS keys to a log file 2022-02-09 21:23:25 +01:00
LibUnicode LibUnicode: Implement sentence segmentation 2022-01-31 21:05:04 +02:00
LibUSBDB LibCore+AK: Move MappedFile from AK to LibCore 2021-11-23 11:33:36 +01:00
LibVideo AK: Move integral log2 and exp to IntegerMath.h 2022-02-06 17:52:33 +00:00
LibVT Userland: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
LibWasm Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
LibWeb LibWeb: Remove CascadeOrigin::Any enum value 2022-02-11 15:21:56 +01:00
LibWebSocket LibCore+Userland: Remove Core::TCPSocket :^) 2022-02-06 17:28:17 +00:00
LibX86 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
CMakeLists.txt LibEDID: Add a library to parse EDID blobs 2022-01-23 22:45:21 +00:00