Skip to content

Commit de0818e

Browse files
committed
Add more info in readme.
1 parent e81e7ee commit de0818e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ set(PLTHook_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/plthook")
7373

7474
FetchContent_Declare(PLTHook
7575
GIT_REPOSITORY https://github.com/metacall/plthook.git
76-
GIT_TAG master
76+
GIT_TAG feature/delayload-win32 # master
7777
SOURCE_DIR ${PLTHook_SOURCE_DIR}
7878
)
7979

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The feature once implemented will solve the following isuses:
1010

1111
## How it works
1212

13+
This PoC is based on a modified version of [PLTHook Library](https://github.com/metacall/plthook) from [@kubo](https://github.com/kubo).
14+
1315
First of all we have the following preconditions:
1416
- `libmetacall` which loads `libnode_loader`.
1517
- `libnode_loader` is not linked to anything but we are going to weakly link it to `libnode`, this means that in Windows it must be linked with `/DELAYLOAD`, in Linux and MacOS it must not be linked.
@@ -38,5 +40,17 @@ There are two possible cases, this happens before loading libnode_loader:
3840

3941
## Outcome
4042

41-
With this methodology we prevent loading a library that contains a runtime. This is very dangerous because numerous runtimes rely on constructors (C++ constructors of static class delacarations or C compiler dependant constructor mechanisms like GNU or Clang `__attribute__((destructor))`) that are mutually exclusive between them. So if we only load the library but we do not call method of the library, it can still cause errors.
43+
With this methodology we prevent loading a library that contains a runtime. This is very dangerous because numerous runtimes rely on constructors (C++ constructors of static class delacarations or C compiler dependant constructor mechanisms like GNU or Clang `__attribute__((constructor))`) that are mutually exclusive between them. So if we only load the library but we do not call method of the library, it can still cause errors.
4244
The loaders will be redirected to the proper runtime, reusing the functions and instance of the already running runtime.
45+
46+
## Features
47+
48+
- Works for Linux, Windows and MacOS with most of the architectures of each platform: https://github.com/metacall/plthook?tab=readme-ov-file#supported-platforms
49+
- Hooks the functions and prevents runtime instances to be initialized, so it's fully transparent and has no side effects on the runtimes.
50+
51+
## Limitations
52+
53+
- Currently it does not support `-O3` on Linux with GCC compiler, neither `/O2` and `/Ob2`. Works in MacOS with `-O3` and Clang.
54+
- It does not work well (https://github.com/kubo/plthook/issues/51) with `aarch64` architecture under Linux with the following flags:
55+
- Library: `-shared -fPIC -Wall -Wl,-z,relro,-z,now -O3`
56+
- Executable: `-fPIE -pie -Wall -Wl,-z,relro,-z,now -O3`

0 commit comments

Comments
 (0)