Commit Graph

363 Commits

Author SHA1 Message Date
Folkert
7ab46a144b
cleanup 2022-10-15 20:12:06 +02:00
Folkert
fdd921aeeb
add extra fields to metadata 2022-10-15 20:09:56 +02:00
Folkert
7529e10580
wip 2022-10-15 19:15:56 +02:00
Folkert
19ea3489cb
provide more libc functions for the expect implementation 2022-10-12 20:59:18 +02:00
Ayaz
3d17307bde
Merge pull request #4275 from roc-lang/surgical-error-msg
Give an error message when the surgical linker #3609
2022-10-10 10:08:33 -05:00
dependabot[bot]
1a9323ecdc
Bump libc from 0.2.133 to 0.2.135
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.133 to 0.2.135.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.133...0.2.135)

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 13:00:20 +00:00
Brendan Hansknecht
3cf4459ea6
filter out debug and eh relocatoins 2022-10-09 15:48:23 -07:00
Brendan Hansknecht
b306c9a76b
give an error message when the surgical linker would fail with know issue #3609 2022-10-09 11:39:10 -07:00
Folkert
5dbd119391
WIP 2022-10-03 21:19:09 +02:00
Folkert
c3d49ab38b
improve write_dummy_sections style 2022-10-02 18:21:30 +02:00
Folkert
7a04c1e801
preprocess itself produces a functioning binary 2022-10-02 17:19:19 +02:00
Folkert
355bbcb3a7
improve comment 2022-10-02 15:48:36 +02:00
Folkert
57e67f9878
ignore a test that does not yet work on windows 2022-10-02 15:43:39 +02:00
Folkert
675092db17
add a test for preprocessing 2022-10-02 15:41:15 +02:00
Folkert
78a5902261
on windows, run the .exe with the full path 2022-10-02 15:40:34 +02:00
Folkert
06e24fb44f
bump image size 2022-10-02 15:39:24 +02:00
Folkert
a798552dee
write valid dummy sections 2022-10-02 15:37:53 +02:00
Folkert
cf23feb996
track section alignment 2022-10-02 15:33:00 +02:00
Folkert
249901c73c
add libc functions to the linker crate, so we can run tests on windows 2022-10-02 15:29:24 +02:00
Folkert de Vries
2b91154b93
Merge pull request #4128 from roc-lang/static-relocations
PE inter-section relocations
2022-10-01 00:01:56 +02:00
Folkert
28eb6cc498
remove absolute again; this test does not actually test it 2022-09-29 21:37:35 +02:00
Folkert
1a7025b20c
clippy things 2022-09-29 00:27:28 +02:00
Folkert
1254c9f8db
clippy 2022-09-28 20:39:16 +02:00
Folkert
4780144e38
simplify PE tests 2022-09-28 20:36:00 +02:00
Folkert
ba704d731f
do inter-app relocations (PE) 2022-09-28 20:35:27 +02:00
Folkert
d70625b21b
improved symbol debugging output from the surgical linker 2022-09-28 14:11:54 +02:00
Brian Carroll
173a4ec8ab
Define roc_memmove in case LLVM decides to use memmove 2022-09-27 21:24:23 +01:00
Folkert
b725b36697
add support for absolute relocations 2022-09-25 19:09:56 +02:00
Folkert
fdbb0c8e3c
rename LittleEndian -> LE 2022-09-25 13:54:52 +02:00
Folkert
65fd6e9e86
add a zig-based elf linker test 2022-09-25 13:46:03 +02:00
Folkert
9ba0103715
only pass endianness down 2022-09-25 13:09:58 +02:00
Folkert
fbe3f359e2
fix a test 2022-09-25 01:51:16 +02:00
Folkert
49eff224bc
split elf and macho linking into their own files 2022-09-25 01:14:03 +02:00
Folkert
89938cc80e
pass the roc app bytes into the linker
as opposed to opening a file 'within' the linker
2022-09-24 23:03:43 +02:00
Folkert
320aa504cd
fix underflow in duration calculation 2022-09-24 22:53:54 +02:00
Folkert
1d875a32fb
bubble up Path 2022-09-24 17:41:11 +02:00
Folkert
55aee0c6ab
extract metadata collection 2022-09-24 17:17:00 +02:00
Folkert
764637594e
centralize mmap logic 2022-09-24 16:55:53 +02:00
Folkert
baa0dcc359
more paths 2022-09-24 16:26:36 +02:00
Folkert
3f87c1b60c
cleanup 2022-09-24 16:09:55 +02:00
Folkert
c220f0c296
open host with an mmap 2022-09-24 15:46:08 +02:00
Folkert
cbc04acc2c
remove a magic constant 2022-09-24 15:14:04 +02:00
Folkert
f1e05f6d13
centralize metadata file IO 2022-09-24 14:49:23 +02:00
Folkert
51f8bf496f
remove magic constant 2022-09-24 14:40:36 +02:00
Folkert
f88dc0308b
restructure the preprocessing entry point 2022-09-24 14:40:24 +02:00
Folkert
71a26d32d2
remove unused argument 2022-09-24 14:16:58 +02:00
Folkert
1251769eb5
add comment to metadata 2022-09-24 13:55:51 +02:00
Folkert
0b4682a73f
remove a magic offset 2022-09-24 13:48:58 +02:00
Folkert
228e5d831d
remove dead_code pragmas 2022-09-24 13:32:07 +02:00
Folkert
baed73d9f2
renaming 2022-09-23 20:57:57 +02:00
Folkert
f7a2eff34b
refactor 2022-09-23 20:48:41 +02:00
Folkert
3131bd1a2f
Merge remote-tracking branch 'origin/pe-host-to-app' into windows-surgical-linker-first-roc-file 2022-09-23 20:17:42 +02:00
Folkert
f632e299cd
cross-compile C for windows with zig 2022-09-23 19:46:27 +02:00
Folkert
aae2dbf17c
remove test we don't need any more 2022-09-23 18:29:27 +02:00
Folkert
d871e2a14f
add the -rdynamic flag 2022-09-23 14:52:52 +02:00
Folkert
8811123811
add .exe extension when target is windows 2022-09-23 14:52:52 +02:00
Folkert
8634f284b5
call host functions from the app 2022-09-23 14:52:51 +02:00
Folkert
78e1328064
remove magic constant 2022-09-23 14:52:51 +02:00
Folkert
eca17a493f
Revert "some work on a .dll import section; immediately revert"
This reverts commit f151044afc.
2022-09-23 14:52:51 +02:00
Folkert
e5a2726daf
some work on a .dll import section; immediately revert 2022-09-23 14:52:50 +02:00
Folkert
438bc0e602
use the -rdynamic flag to have zig produce an export section for the host 2022-09-23 14:52:50 +02:00
Folkert
fd5e0c9dda
missed some renames 2022-09-23 11:26:17 +02:00
Folkert
fae1d96474
more renames 2022-09-23 11:26:16 +02:00
Folkert
84b5a3479b
refactor (this is useful later for actual surgical linking 2022-09-23 11:26:16 +02:00
Folkert
b9b5dd32b2
rename some things 2022-09-23 11:26:16 +02:00
Folkert
3c5355aa2d
add comment 2022-09-23 11:26:16 +02:00
Folkert
87cdc6a9c7
refactor section header writing 2022-09-23 11:26:15 +02:00
Folkert
45d47e9ad5
add windows test 2022-09-23 11:26:15 +02:00
Folkert
0eafaaf977
cleanup 2022-09-23 11:26:15 +02:00
Folkert
63303844dd
support multiple symbols (from the same section) 2022-09-23 11:26:14 +02:00
Folkert
2a5d22739d
support multiple text and rdata sections 2022-09-23 11:26:14 +02:00
Folkert
cc0ee8c2fd
use an exported constant in the host 2022-09-23 11:26:14 +02:00
Folkert
8a6a126c19
copy in the app's .rdata section 2022-09-23 11:26:13 +02:00
Folkert
e2f799b6e0
fold experimental stuff into old test 2022-09-23 11:26:13 +02:00
Folkert
0f7c8c37bf
more cleanup 2022-09-23 11:26:13 +02:00
Folkert
9777ae64a5
slowly cleaning up 2022-09-23 11:26:12 +02:00
Folkert
3229a10764
actually append the app bytes into the new section 2022-09-23 11:26:12 +02:00
Folkert
d5cd4776c0
using the mmap 2022-09-23 11:26:12 +02:00
Folkert
004a9895fa
empty second text section 2022-09-23 11:26:11 +02:00
Folkert
59b4699668
extra .text section created 2022-09-23 11:26:11 +02:00
Folkert
dbc5f9e3e7
get rid of a copy of the data 2022-09-23 00:25:20 +02:00
Folkert
c9c08a28ec
cleanup 2022-09-23 00:16:31 +02:00
Folkert
79337f1333
move more into the dynhost 2022-09-23 00:15:54 +02:00
Folkert
8f7497acb7
write import directory size in the dynhost, not the executable 2022-09-23 00:13:11 +02:00
Folkert
32dab538ea
refactor 2022-09-23 00:07:28 +02:00
Folkert
2631970851
use mmap 2022-09-23 00:06:57 +02:00
Folkert
56bf57dab1
improve calculation of section index 2022-09-23 00:04:57 +02:00
Folkert
1c8b717af4
Revert "move the erasing of the .dll information to the precompiled host"
This reverts commit ba8baae0dc.
2022-09-22 23:51:52 +02:00
Folkert
ba8baae0dc
move the erasing of the .dll information to the precompiled host 2022-09-22 23:45:17 +02:00
Folkert
5b9e152248
use cached dynamic_relocations 2022-09-22 21:58:54 +02:00
Folkert
1ebcf25fc0
cleanup 2022-09-22 21:56:40 +02:00
Folkert
9bbe0e029f
refactor 2022-09-22 21:55:31 +02:00
Folkert
540d3c29f9
enable the windows surgical linker, for now 2022-09-22 21:53:48 +02:00
Folkert
1c95fd3761
a functional windows surgical linker 2022-09-22 21:28:27 +02:00
Folkert
466b5d78cb
linking of a very simple roc program 2022-09-22 00:32:36 +02:00
Folkert
e88b61734c
add .exe extension when target is windows 2022-09-21 18:11:59 +02:00
Folkert
05feeeb253
call host functions from the app 2022-09-21 17:42:08 +02:00
Folkert
7399dc8ae4
remove magic constant 2022-09-21 15:27:33 +02:00
Folkert
0cc75ae27c
Revert "some work on a .dll import section; immediately revert"
This reverts commit f151044afc.
2022-09-21 15:26:52 +02:00
Folkert
f151044afc
some work on a .dll import section; immediately revert 2022-09-21 15:26:44 +02:00
Folkert
fcc17f6b68
use the -rdynamic flag to have zig produce an export section for the host 2022-09-21 15:26:03 +02:00
Folkert
2d2fbfd987
add comment 2022-09-21 12:37:48 +02:00
Folkert
8f5b005f10
refactor section header writing 2022-09-21 12:32:43 +02:00
Folkert
20cd50f712
add windows test 2022-09-20 23:56:52 +02:00
Folkert
841a553839
cleanup 2022-09-20 23:56:19 +02:00
Folkert
a3fc426752
support multiple symbols (from the same section) 2022-09-20 23:51:03 +02:00
Folkert
42f725bb51
support multiple text and rdata sections 2022-09-20 21:00:31 +02:00
Folkert
ec0ac1cf55
use an exported constant in the host 2022-09-20 20:11:44 +02:00
Folkert
66a83a9705
copy in the app's .rdata section 2022-09-19 18:08:17 +02:00
Folkert
631a1b6302
fold experimental stuff into old test 2022-09-19 15:23:47 +02:00
Folkert
3cd2bf6ad4
more cleanup 2022-09-19 15:21:34 +02:00
Folkert
3ca3aae549
slowly cleaning up 2022-09-19 15:08:47 +02:00
Folkert
05aba03b87
actually append the app bytes into the new section 2022-09-19 12:50:02 +02:00
Folkert
322091353e
using the mmap 2022-09-19 12:03:02 +02:00
Folkert
4c8475fb74
empty second text section 2022-09-19 11:59:45 +02:00
Folkert
28fb72cca3
extra .text section created 2022-09-19 11:54:45 +02:00
Folkert
2b0ec6c227
help the type checker 2022-09-19 11:36:47 +02:00
Folkert
b881af47cb
first surgical link on PEs 2022-09-19 10:43:37 +02:00
Folkert
841c478b98
update the length of imports in the data directory after removing our dummy dll 2022-09-18 17:23:50 +02:00
Folkert
6005ed0664
add test that combines a zig platform with a dll 2022-09-18 14:11:46 +02:00
Folkert
61366f0d43
add test for preprocessing on a zig host 2022-09-18 13:42:21 +02:00
Folkert
daa7e72a2f
clarify comment 2022-09-18 01:00:36 +02:00
Folkert
270949aa07
Revert "add test for preprocessing on a zig host"
This reverts commit 5ee12aeb7d.
2022-09-18 00:58:34 +02:00
Folkert
5ee12aeb7d
add test for preprocessing on a zig host 2022-09-18 00:58:27 +02:00
Folkert
4f51f18a08
remove a constant, add an assert 2022-09-18 00:32:55 +02:00
Folkert
c7bb2672a9
fix typo 2022-09-17 14:44:37 +02:00
Folkert
92514a1499
custom logic around finding 'forward' exports 2022-09-17 14:42:36 +02:00
Folkert
0da6484618
add some asserts about addresses in the dummy dll generation 2022-09-17 14:37:10 +02:00
Brian Carroll
b0c4f74109
Add some extra context clues to a name and a comment 2022-09-17 07:44:41 +01:00
Folkert
c00e458bad
refactor 2022-09-15 20:06:07 +02:00
Folkert
bad715e18a
add some objdump snippets to make clearer what is happening 2022-09-15 19:37:28 +02:00
Folkert
132ea07191
refactor out a constant 2022-09-15 19:37:12 +02:00
Folkert
1b74dec8ac
remove test 2022-09-14 21:19:39 +02:00
Folkert
cead509255
comment out test 2022-09-14 21:19:25 +02:00
Folkert
d8c0c176d8
comment 2022-09-14 18:31:27 +02:00
Folkert
2e8952d8a7
windows PE preprocessing of the .exe 2022-09-14 18:02:01 +02:00
Folkert de Vries
3ee3f23836
Merge pull request #3971 from roc-lang/dependabot/cargo/bumpalo-3.11.0
Bump bumpalo from 3.10.0 to 3.11.0
2022-09-13 21:00:00 +02:00
Folkert de Vries
bed73f5b2e
Merge pull request #3986 from roc-lang/pe-dynamic-relocations
find and decode the dynamic relocations in .exe files
2022-09-13 10:28:54 +02:00
dependabot[bot]
0079048944
Bump bumpalo from 3.10.0 to 3.11.0
Bumps [bumpalo](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.11.0.
- [Release notes](https://github.com/fitzgen/bumpalo/releases)
- [Changelog](https://github.com/fitzgen/bumpalo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/bumpalo/compare/3.10.0...3.11.0)

---
updated-dependencies:
- dependency-name: bumpalo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 21:08:56 +00:00
Ayaz
08c5903a48
Merge pull request #4017 from roc-lang/dependabot/cargo/serde-1.0.144
Bump serde from 1.0.139 to 1.0.144
2022-09-12 12:44:14 -04:00
dependabot[bot]
35b2e9c80f
Bump clap from 3.2.18 to 3.2.20
Bumps [clap](https://github.com/clap-rs/clap) from 3.2.18 to 3.2.20.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.20/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.2.18...v3.2.20)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 10:33:19 +00:00
dependabot[bot]
555ed2c7fc
Bump serde from 1.0.139 to 1.0.144
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.139 to 1.0.144.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.139...v1.0.144)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 05:28:20 +00:00
Folkert
af8f54bfbd
find and decode the dynamic relocations in .exe files 2022-09-07 17:52:19 +02:00
Folkert
6fff224c77
PE cleanup after review elsewhere 2022-09-07 14:07:52 +02:00
Folkert
8a2aa076ee
cleanup 2022-09-07 14:07:52 +02:00
Folkert
c46f8a0073
create a dummy elf .so from scratch 2022-09-07 14:07:52 +02:00
Folkert de Vries
bdbaa9dda2
Merge pull request #3956 from roc-lang/refactor-surgery
minor cleanup of surgery
2022-09-06 19:17:02 +02:00
Folkert de Vries
33ae4c2655
Merge branch 'main' into windows-surgical-dll
Signed-off-by: Folkert de Vries <folkert@folkertdev.nl>
2022-09-05 11:31:19 +02:00
Folkert
af74f72f8a
minor tweaks 2022-09-03 14:45:22 +02:00
Folkert
ff7df65f36
simplify slices 2022-09-03 13:24:21 +02:00
Folkert de Vries
7e31f67910
Merge pull request #3919 from roc-lang/surgical-no-break-caching
surgical linker: don't generate dynhost if it's unchanged
2022-08-31 09:04:13 +02:00
Folkert
ab2163b800
sort symbols 2022-08-30 15:00:58 +02:00
dependabot[bot]
048766cb3a
Bump memmap2 from 0.5.5 to 0.5.7
Bumps [memmap2](https://github.com/RazrFalcon/memmap2-rs) from 0.5.5 to 0.5.7.
- [Release notes](https://github.com/RazrFalcon/memmap2-rs/releases)
- [Changelog](https://github.com/RazrFalcon/memmap2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/RazrFalcon/memmap2-rs/compare/v0.5.5...v0.5.7)

---
updated-dependencies:
- dependency-name: memmap2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-30 12:34:16 +00:00
Folkert de Vries
5c7acf8f72
Merge pull request #3933 from roc-lang/dependabot/cargo/clap-3.2.18
Bump clap from 3.2.11 to 3.2.18
2022-08-30 14:32:41 +02:00
Folkert
3e78395237
changes after review 2022-08-30 12:32:19 +02:00
dependabot[bot]
492eff3556
Bump clap from 3.2.11 to 3.2.18
Bumps [clap](https://github.com/clap-rs/clap) from 3.2.11 to 3.2.18.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.18/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.2.11...v3.2.18)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-30 10:17:11 +00:00
Brendan Hansknecht
ed7f066d33
Merge pull request #3916 from roc-lang/surgical-text-surgeries
surgical linker: extract finding surgeries in text
2022-08-30 03:00:26 +00:00
Folkert
d9db0b7096
fix shared object file extension 2022-08-30 00:15:48 +02:00
Folkert
835d3b9eb0
move stuff into files 2022-08-30 00:10:44 +02:00
Folkert
62a818883a
generate a minimal, fake .dll with the host-exposed symbols 2022-08-29 23:58:05 +02:00
Brendan Hansknecht
3895abd540
Merge pull request #3915 from roc-lang/surgical-use-struct-syntax
surgical linker: use struct initialization syntax
2022-08-29 03:00:34 +00:00
Folkert
d433448d6f
don't regenerate the dynhost file if it is unchanged 2022-08-28 13:17:50 +02:00
Richard Feldman
3ca9202e3b
Merge pull request #3834 from roc-lang/rust-1.63-clippy
rust 1.63 clippy
2022-08-27 21:15:36 -04:00
Folkert
0ca79c7a60
add some comments 2022-08-28 00:12:48 +02:00
Folkert
764b9f656e
simplify pattern 2022-08-28 00:08:07 +02:00
Folkert
2bc809503a
extract looking at the text sections 2022-08-28 00:07:29 +02:00
Folkert
e009f7888e
prettify 2022-08-27 23:30:00 +02:00
Folkert
476521e7b7
use struct initialization syntax 2022-08-27 23:23:08 +02:00
Folkert
57c12b009b
find the undefined symbols 2022-08-27 12:21:49 +02:00
Folkert
0238471241
add a test for extracting symbols from a dynhost 2022-08-27 12:19:06 +02:00
Folkert
c4d25e0180
extract symbol collecting logic 2022-08-27 12:17:29 +02:00
Folkert
45b32106ec
add an example dynhost elf file 2022-08-27 12:16:28 +02:00
Folkert de Vries
a8b83cfe37
Merge pull request #3858 from roc-lang/surgical-generate-dylib
Surgical generate dylib
2022-08-25 09:03:52 +02:00
Folkert
87988a301b
cleanup 2022-08-24 12:34:08 +02:00
Folkert
0a2ffc8ba4
rename 2022-08-23 21:20:44 +02:00
Folkert
e609919f39
cleanup 2022-08-23 21:20:23 +02:00
Folkert
daee025ff6
more hardcoding 2022-08-23 21:15:32 +02:00
Folkert
df77b8bac1
simplify reserving of alloc sections 2022-08-23 16:09:25 +02:00
Folkert
3431182ac9
simplify dynamic section hack 2022-08-23 15:37:12 +02:00
Folkert
9cef677674
refactor 2022-08-23 15:35:44 +02:00
Folkert
d3db9a0fef
more hardcoding 2022-08-23 15:32:47 +02:00
Folkert
0fb137cc93
hardcode the dynamic section content 2022-08-23 15:14:42 +02:00
Folkert
164265f315
strip hash some more 2022-08-23 14:48:13 +02:00
Folkert
9b2a43639b
unroll a loop 2022-08-23 14:34:26 +02:00
Folkert
d7499ce928
hardcode some hash table properties 2022-08-23 14:17:30 +02:00
Folkert
fd5e9a9b48
stop sorting symbols before hashing 2022-08-23 14:12:06 +02:00
Folkert
597b4752dc
rename MySection -> Section 2022-08-23 14:05:57 +02:00
Folkert
f4a388ce90
cleanup 2022-08-23 14:02:19 +02:00
Folkert
fcead21c17
remove .ehframe section from the dylib 2022-08-23 14:00:54 +02:00
Folkert
a7ab08b2ba
cleanup 2022-08-21 21:10:40 +02:00
Folkert
88c8ee6c93
use our section iterator instead of in_sections 2022-08-21 21:06:30 +02:00
Folkert
4e9bff9eb6
don't add our symbols to the eh_frame section; it's not needed 2022-08-21 20:41:31 +02:00
Folkert
f3f6f58d09
clippy fixes 2022-08-21 16:43:57 +02:00
Folkert
5261005096
more cleanup 2022-08-21 15:50:12 +02:00
Folkert
5035d022e0
cleanup 2022-08-21 15:36:48 +02:00
Folkert
0005635899
refactor section reserving 2022-08-21 15:30:46 +02:00
Folkert
729e556534
fake it well enough that cli tests all pass 2022-08-21 15:19:39 +02:00
Folkert
08e4abbf0a
reorder section writing to be correct 2022-08-21 14:21:02 +02:00
Folkert
9efa02c569
add more sections 2022-08-20 21:18:08 +02:00
Folkert
51a187c717
cleanup 2022-08-20 17:18:21 +02:00