1363 Commits

Author SHA1 Message Date
Jakub Konka
5ef33e7c7e
Merge pull request #13459 from ziglang/issue-13457
macho: do not zero-out file if there are no nonzerofill sects
2022-11-06 08:39:13 +01:00
Jakub Konka
76fb3e0621 macho: do not zero-out file if there are no nonzerofill sects
If the `__DATA` segment comprises of only zerofill sections, do not
accidentally zero out all of file.
2022-11-06 00:36:27 +01:00
Jakub Konka
165ae04a03 coff: use .x86 instead of .i386 2022-11-05 10:35:04 +01:00
Jakub Konka
59fa0499c9 coff: tentatively handle Obj in getImageBase() func 2022-11-05 10:15:01 +01:00
Jakub Konka
9618fdc8a2 coff: circumvent stage1 inference problems 2022-11-05 10:15:01 +01:00
Jakub Konka
83d89a05b7 coff: compile and link simple exit program on arm64
* make image base target dependent
* fix relocs to imports
2022-11-05 10:15:01 +01:00
Jakub Konka
205421c311 coff: implement handling of arm64-specific relocs 2022-11-05 10:15:00 +01:00
Jakub Konka
d80203b55d coff: clean up relocation handling between x86 and arm64 2022-11-05 10:15:00 +01:00
Jakub Konka
53a9661c1a coff: generate relocations for branch, GOT, direct refs 2022-11-05 10:15:00 +01:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
Cody Tapscott
6f2408aab8 link/MachO: Avoid depending on host PATH_MAX
Repeat of a4eb221b9 for the newly-synchronized zld code.

Restores ability to compile Zig for WASI.
2022-10-31 13:12:37 -04:00
Jakub Konka
9b0c555db4 macho: fix regression in dead strip for x86_64
Correctly handle calculating encompassing atoms for local
relocations (`r_extern == 0`).
2022-10-30 10:49:00 +01:00
Jakub Konka
27bcd4ec79 macho: do not unnecessarily dupe sym names in resolver 2022-10-30 10:12:25 +01:00
Andrew Kelley
5f5a20ebaf
Merge pull request #13093 from jacobly0/backend-fixes
C backend fixes
2022-10-29 23:06:59 -04:00
Andrew Kelley
28dc208f65
Merge pull request #13082 from g-w1/unnamed-decls-and-relocs-p9
Plan9: Fix The Backend
2022-10-29 17:45:00 -04:00
Jacob Young
48a2783969 cbe: implement optional slice representation change 2022-10-29 05:58:41 -04:00
Luuk de Gram
c0710b0c42
use fixed-size arrays for feature lists
Considering all possible features are known by the linker during
compile-time, we can create arrays on the stack instead of
dynamically allocating hash maps. We use a simple bitset to determine
whether a feature is enabled or not, and from which object file
it originates. This allows us to make feature validation slightly
faster and use less runtime memory.
In the future this could be enhanced further by having a single
array instead with a more sophisticated bitset.
2022-10-25 21:16:51 +02:00
Luuk de Gram
3d1d19f387
wasm-linker: seperate linker -and cpu features
The list of features a Wasm object/binary file can emit can differ
from the list of cpu features. The reason for this is because the
"target_features" section also contains linker features. An example
of this is the "shared-mem" feature, which is a feature for the linker
and not that of the cpu target as defined by LLVM.
2022-10-25 20:48:09 +02:00
Luuk de Gram
777bcbf968
wasm-linker: emit target_features section
When the result is not being stripped, we emit the `target_features`
section based on all the used features. This includes features
inferred from linked object files.
Considering we know all possible features upfront, we can use an
array and therefore do not have to dynamically allocate memory.
Using this trick we can also easily order all features based
the same ordering as found in `std.Target.wasm` which is the same
ordering used by LLVM and the like.
2022-10-25 20:48:08 +02:00
Luuk de Gram
85b669d497
wasm-linker: validate feature compatibility
Verifies disallowed and used/required features. After verifying,
all errors will be emit to notify the user about incompatible
features. When the user did not define any featureset, we infer
the features from the linked objects instead.
2022-10-25 20:48:05 +02:00
Jacob Young
65a48df532 cbe: fix globals that reference functions
Global constant initializers can reference functions, so forward declare
the constants and initialize them later with the function definitions,
which guarantees that they appear after all declarations.
2022-10-25 05:11:29 -04:00
Jacob Young
1dd4a6102f cbe: implement global assembly 2022-10-25 05:11:29 -04:00
Jacob Young
6a4266d62a cbe: fix infinite recursion on recursive types 2022-10-25 05:11:28 -04:00
Jacob Young
7c9a9a0fd4 cbe: cleanup code and fix cases test breakage 2022-10-25 05:11:28 -04:00
Jacob Young
6f3654ad69 c: implement @errorName 2022-10-25 05:11:28 -04:00
Jacob Young
c8d0e71de6 c: fix mangling of error names
Closes #12751
2022-10-25 05:11:28 -04:00
Andrew Kelley
b3cd38ea4a link: add an explicit error set for flush() and flushModule()
This makes it easier to understand how control flow should happen in
various cases; already just by doing this it is revealed that
UndefinedSymbol and UndefinedSymbolReference should be merged, and that
MissingMainEntrypoint should be removed in favor of the ErrorFlags
mechanism thath we already have for missing the main entrypoint.

The main motivation for this change, however, is preventing a compile
error when there is conditional compilation inside linker
implementations, causing the flush() error set to depend on compilation
options. With this change, the error set is fixed, and, notably, the
`-Donly-c` flag no longer has compilation errors due to this error set.
2022-10-24 23:30:57 -07:00
Jacob G-W
5aef54cbc8 additional fixes for Plan9
with this, the tests should pass
2022-10-24 17:01:26 -04:00
Jacob G-W
6cba18fe60 Add relocations to the plan9 backend 2022-10-24 16:53:12 -04:00
Jacob G-W
5cf3d10e35 Plan9: deal with unnamed decls
Hello World works again!
2022-10-24 16:53:12 -04:00
Jakub Konka
828735ac03 macho: handle majority of DW_FORM_ values for DWARF4 in the linker 2022-10-23 21:53:36 +02:00
Jakub Konka
2f37278540 macho: temp hash buffer has to live as long as pread error resolution 2022-10-23 10:15:42 +02:00
Jakub Konka
1bbafbc65f macho: increment temp buffer when calculating hashes 2022-10-23 09:58:47 +02:00
Andrew Kelley
4a2f1e748e link.MachO: multi-thread first round of sha256 hashing
when computing the adhoc code signature
2022-10-22 16:03:59 -07:00
Jakub Konka
593b75b109 macho: some docs 2022-10-22 14:53:53 +02:00
Jakub Konka
086cee844a macho: refactor dead code stripping conditions
1. If an object file was not compiled with `MH_SUBSECTIONS_VIA_SYMBOLS`
   such a hand-written ASM on x86_64, treat the entire object file as
   not suitable for dead code stripping aka a GC root.
2. If there are non-extern relocs within a section, treat the entire
   section as a root, at least temporarily until we work out the exact
   conditions for marking the atoms live.
2022-10-22 07:59:24 +02:00
Jakub Konka
0cc4d54781 macho: do not skip over SUBTRACTOR reloc when dead stripping 2022-10-22 07:59:24 +02:00
Jakub Konka
f8cbe29a17 macho: fix incorrect lookup of symbols when calculating subtractors 2022-10-22 07:59:24 +02:00
Jakub Konka
93cc5496e1 macho: rewrite movq to leaq when TLV is not external pointer 2022-10-22 07:59:24 +02:00
Jakub Konka
5823f19c5e macho: gracefully handle uninitialized symtabs in objects 2022-10-22 07:59:24 +02:00
Jakub Konka
2c2ff4558f macho: fix handling of lack of subsections and tracking of inner symbols 2022-10-22 07:59:24 +02:00
Jakub Konka
5edb8e0b8f macho: relax SUBTRACTOR assumption it not being a defined global 2022-10-22 07:59:23 +02:00
Jakub Konka
bc1e714de6 macho: revert changes to file descriptors mgmt 2022-10-22 07:59:23 +02:00
Jakub Konka
15f1e6a60c macho: fix silly error where we would incorrectly skip a valid binding 2022-10-22 07:59:23 +02:00
Jakub Konka
c15e03ac79 macho: fix bug in incorrectly splicing nodes in trie 2022-10-22 07:59:23 +02:00
Jakub Konka
5b9eaf2938 macho: do not assume __la_symbol_ptr was created 2022-10-22 07:59:23 +02:00
Jakub Konka
33d1942f27 macho: always create __TEXT segment 2022-10-22 07:59:23 +02:00
Jakub Konka
e70adc7f1a macho: skip parsing __eh_frame until we know how to handle it 2022-10-22 07:59:23 +02:00
Jakub Konka
baceaf65f2 macho: fix incorrectly erroring out with multiple sym definition 2022-10-22 07:59:23 +02:00
Jakub Konka
a32bc0e39c macho: fix 32bit build 2022-10-22 07:59:23 +02:00