diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-13 16:09:47 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-13 16:35:45 +0200 |
| commit | 3f35d6984fa7e90a86cae3d6769cc2f1036bbdde (patch) | |
| tree | b27744b59fa8979ea258d72375c334e45a706546 /src/codegen.zig | |
| parent | 887da399eb266b166d1a109bdfe631f4533ead64 (diff) | |
| download | zig-3f35d6984fa7e90a86cae3d6769cc2f1036bbdde.tar.gz zig-3f35d6984fa7e90a86cae3d6769cc2f1036bbdde.zip | |
x86_64: make TLV a separate MCValue
Diffstat (limited to 'src/codegen.zig')
| -rw-r--r-- | src/codegen.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/codegen.zig b/src/codegen.zig index e00141db97..6939b750fd 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -912,13 +912,11 @@ fn lowerDeclRef( /// * got - the value is referenced indirectly via GOT entry index (the linker emits a got-type reloc) /// * direct - the value is referenced directly via symbol index index (the linker emits a displacement reloc) /// * import - the value is referenced indirectly via import entry index (the linker emits an import-type reloc) -/// * tlv - the value is a threadlocal variable referenced indirectly via GOT (the linker emits a got-type reloc) pub const LinkerLoad = struct { type: enum { got, direct, import, - tlv, }, sym_index: u32, }; @@ -934,6 +932,10 @@ pub const GenResult = union(enum) { /// such as ARM, the immediate will never exceed 32-bits. immediate: u64, linker_load: LinkerLoad, + /// Pointer to a threadlocal variable. + /// The address resolution will be deferred until the linker allocates everything in virtual memory. + /// Payload is a symbol index. + tlv_reloc: u32, /// Direct by-address reference to memory location. memory: u64, }; @@ -1002,8 +1004,11 @@ fn genDeclRef( } else if (bin_file.cast(link.File.MachO)) |macho_file| { const atom_index = try macho_file.getOrCreateAtomForDecl(decl_index); const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?; + if (is_threadlocal) { + return GenResult.mcv(.{ .tlv_reloc = sym_index }); + } return GenResult.mcv(.{ .linker_load = .{ - .type = if (is_threadlocal) .tlv else .got, + .type = .got, .sym_index = sym_index, } }); } else if (bin_file.cast(link.File.Coff)) |coff_file| { |
