27168 Commits

Author SHA1 Message Date
Jakub Konka
da417b851b elf: return error.FlushFailure in flushObject and flushStaticLib codepaths when found errors 2023-12-05 18:12:58 +01:00
Jakub Konka
418b042f49 elf: fix typo 2023-12-05 18:10:09 +01:00
Jakub Konka
d05db52616 elf: copy out committed ZigObject to a buffer when creating static lib 2023-12-05 17:29:26 +01:00
Jakub Konka
ab423bd63c elf: exit early with an error when parsing or init failed when flushing object/archive 2023-12-05 16:35:08 +01:00
Jakub Konka
ee1630beea elf: exit early with an error when parsing or init failed 2023-12-05 16:31:47 +01:00
Jakub Konka
205857e342 elf: refactor 2023-12-05 14:54:03 +01:00
Jakub Konka
297c39ff56 test/link/elf: adjust tests for new errors 2023-12-05 14:40:13 +01:00
Jakub Konka
e3592281da elf: escape invalid token string when reporting an error 2023-12-05 14:39:56 +01:00
Jakub Konka
e349bb2b66 elf: upcast e_shnum to u64 to check for valid ranges 2023-12-05 14:27:03 +01:00
Jakub Konka
b294103c7e elf: report malformed archive when parsing errors 2023-12-05 14:11:45 +01:00
Jakub Konka
52959bba7c elf: re-instate basic error reporting for LD script parser 2023-12-05 14:08:04 +01:00
Jakub Konka
2e1dd1e554 elf: move basic parse error reporting to SharedObject 2023-12-05 13:53:11 +01:00
Jakub Konka
3f42ed3ca2 elf: do not write ELF header if there were errors 2023-12-05 13:49:55 +01:00
Jakub Konka
af8621db2d elf: report error at the point where it is happening 2023-12-05 13:28:47 +01:00
Nan Zhong
72568c131d langref: fix incorrect reference to string literal 2023-12-05 10:17:36 +02:00
Jacob Young
c357b902b0
Merge pull request #18179 from jacobly0/x86_64
x86_64: pass more behavior tests
2023-12-04 18:37:39 -05:00
Jacob Young
c70c333594 x86_64: fix packed struct field reuse 2023-12-04 13:31:54 -05:00
Jacob Young
bdb6546a8f x86_64: fix vector comparisions 2023-12-04 13:09:13 -05:00
Jacob Young
50993a8f08 x86_64: implement more operations on vectors with 1-bit elements 2023-12-04 01:29:07 -05:00
Jacob Young
485e20884c x86_64: implement movement for pointer vectors 2023-12-03 23:07:50 -05:00
Jacob Young
0be7c23f11 Coff: minor fixes
* Update the msdos stub to be eight bytes smaller, which moves the
   machine PE header field into the first 128 bytes of the file,
   allowing it to be matched by a binfmt_misc magic sequence.
   This allows the build system to get the correct error during exec.
 * Fix library name memory leaks in Sema.
2023-12-03 18:18:09 -05:00
Jacob Young
7c85ea65ba x86_64: "implement" aggregate_init for vectors 2023-12-03 13:55:31 -05:00
Jacob Young
82ba9b8560 print_air: fix printing of instruction indices 2023-12-03 11:36:23 -05:00
Jacob Young
e00f1397e3 x86_64: implement some todos 2023-12-03 10:24:03 -05:00
Jacob Young
014833b61f x86_64: implement more compliant vectors 2023-12-03 10:22:06 -05:00
Jacob Young
917b4ad5e0 x86_64: implement more atomic ops 2023-12-03 10:22:06 -05:00
Andrew Kelley
8a8fd47d21
Merge pull request #18176 from jedisct1/aegis_sha512
TLS: The 0x1306 TLS identifier was updated to TLS_AEGIS_256_SHA512
2023-12-03 02:05:59 -08:00
Jacob Young
daf91ed8d1 Air: use typesafe Air.Inst.Index
I need some indices for a thing...
2023-12-03 02:05:06 -08:00
Frank Denis
f276bb107e verify_buffer is not expected to be sentinel-terminated 2023-12-01 20:04:52 +01:00
Frank Denis
9831dc9e0c TLS: The 0x1306 TLS identifier was updated to TLS_AEGIS_256_SHA512
Following the recommendations from [1], the AEGIS specification
and the TLS registry [2] were updated to recommend SHA512 for the
traffic secrets.

[1] https://eprint.iacr.org/2023/913.pdf
[2] https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
2023-12-01 18:00:15 +01:00
Jacob Young
bf5ab54510 test: test with -fstrip and fix failures
Closes #17513
2023-12-01 04:34:50 +00:00
Veikka Tuominen
39a966b0a4 Sema: improve error location for array cat/mul 2023-11-30 13:15:40 +02:00
David Rubin
1e42a3de89
Remove all usages of std.mem.copy and remove std.mem.set (#18143) 2023-11-29 16:03:02 -05:00
Andrew Kelley
cd7ac56a5a
Merge pull request #18155 from Luukdegram/wasm-gc
wasm-linker: implement garbage-collection and performance improvements
2023-11-29 16:00:23 -05:00
tjog
22d7c7d295
std.debug: optimized printLineFromFileAnyOs (#18142)
* std.debug: optimized printLineFromFileAnyOs

Uses mem.indexOfScalar to speed line iteration instead of byte for byte.
Also prints the whole line in a single write (or up to a page size at a
time)

Closes #18099

* add test cases for printLineFromFileAnyOs
2023-11-29 14:58:56 -05:00
Luuk de Gram
4115f70cd3
test/link: update wasm linker tests
Disable garbage-collection for certain tests to ensure the tested
sections are being emitted.
2023-11-28 18:32:31 +01:00
Luuk de Gram
596d1cd5a8
wasm-linker: support --no-gc-sections
By default we garbage-collect sections for Wasm to reduce size, as well
as finish linking quicker (as we have fewer things to do). However,
when the user specifies `--no-gc-sections` we ensure all resolved symbols
get marked and therefore do not get garbage collected.
This is supported in both incremental-mode and traditional linking.
2023-11-28 16:40:26 +01:00
Luuk de Gram
4be3cd2754
wasm-linker: support gc for wasm backend code
When using the Wasm backend, we will now also perform garbage collection
there, to ensure unreferenced symbols do not get parsed nor emit into
the final binary.
2023-11-28 15:47:07 +01:00
Luuk de Gram
8447d4fb1f
wasm-linker: handle debug info during gc
When we encounter a debug info symbol, we initially have to parse it
into an atom to find its relocations. We then go through its relocations
to find out if any of the target symbols are marked alive. When it
finds an alive symbol, we also mark the debug symbol as alive to ensure
this piece of debug info is emit to the binary. When it does not encounter
any alive symbols, the debug symbol remains dead and will be garbage-
collected during `allocateAtoms`.
2023-11-28 15:47:07 +01:00
Luuk de Gram
f7d4f72fd5
wasm-linker: Only emit name of referenced symbols 2023-11-28 15:47:07 +01:00
Luuk de Gram
6f7a9b3144
wasm-linker: deduplicate aliased functions
When multiple symbols point to the same function, we ensure any
other symbol other than the original will be discarded and point
to the original instead. This prevents emitting the same function
code more than once.
2023-11-28 15:47:07 +01:00
Luuk de Gram
8856ba7505
wasm-linker: parse symbols into atoms lazily
Rather than parsing every symbol into an atom, we now only parse them
into an atom when such atom is marked. This means garbage-collected
symbols will also not be parsed into atoms, and neither are discarded
symbols which have been resolved by other symbols. (Such as multiple
weak symbols).

This also introduces a binary search for finding the start index into
the list of relocations. This speeds up finding the corresponding
relocations tremendously as they're ordered ascended by address.

Lastly, we re-use the memory of atom's data as well as relocations
instead of duplicating it. This means we half the memory usage of
atom's data and relocations for linked object files. As we are
aware of decls and synthetic atoms, we free the memory of those
atoms indepedently of the atoms of object files to prevent double-frees.
2023-11-28 15:47:07 +01:00
Luuk de Gram
c986c6c90a
wasm-linker: do not merge unreferenced symbols
When a symbol is unreferenced and therefore garbage-collected, we do
not merge its specific section into the final binary.
2023-11-28 15:47:07 +01:00
Luuk de Gram
589aef1537
wasm-linker: mark symbols and its references
Symbols which are exported to the host, or contain the `NO_STRIP`
flag, will be marked. All symbols which are referenced by this symbol
are marked likewise. We achieve this by parsing all relocations of a
symbol, and then marking the symbol it points to within the relocation.
2023-11-28 15:47:06 +01:00
Luuk de Gram
f3626eb816
wasm-link: ensure TLS global when resolved
When a linked object contains references to the __tls_base symbol,
we lazily create this symbol. However, we wouldn't create the corresponding
Wasm global. This meant its address wasn't set correctly as well as fail
to output it into the `Names` section.
2023-11-28 15:47:03 +01:00
Andrew Kelley
2a32264533 package fetching: catch relative paths that resolve into cache dir
The logic here already caught the case when a dependency path tried to
escape out of the zig cache directory using up directories. However, it
did not catch the case when the relative path tried to reach into a
different path within the zig-cache. For example, if it asked for
"../../../blah" then it would be caught, but if it asked for "../blah"
then it would try to resolve as "zig-cache/p/blah" and probably result
in file-not-found, or perhaps resolve to a different package if someone
inadvertently used a valid package hash instead of "blah".

Now it correctly gives a "dependency path outside project" error,
however, still allows relative paths with up-dirs that were not fetched
via URL.
2023-11-28 04:14:41 -05:00
Carter Snook
a98d4a66e9 std.net: replace @ptrCast with slice syntax 2023-11-27 23:14:07 -05:00
Carter Snook
a0fbc6815c std.zig.system: remove explicit usize cast
The cast seems to no longer be necessary after changes in interactions
between `u64` and `usize`.
2023-11-27 23:13:30 -05:00
Bogdan Romanyuk
7fbbeae617
value: handle lazy_align and lazy_size in writeToPackedMemory 2023-11-27 12:35:29 +00:00
Andrew Kelley
89572c6342
Merge pull request #18138 from ziglang/fetch-save
`zig fetch`: add `--save` flag
2023-11-27 04:47:44 -05:00