Commit Graph
86 Commits
Author SHA1 Message Date
Justus Klausecker 69a26976ed zig fmt
Converts usages of `@intFromEnum` and `@enumFromInt` to instead use the
new `@backingInt` and `@fromBackingInt` builtins.
2026-07-17 23:30:26 +02:00
kcbanner f2a778ca52 Coff: fixes for 32 bit targets 2026-06-23 00:27:17 -04:00
kcbanner b2eee06bd6 objdump: coff --tls 2026-06-23 00:26:57 -04:00
kcbanner 97bf880486 objdump: coff --imports 2026-06-23 00:26:57 -04:00
kcbanner 9df2ca0d33 objdump: more coff progress
- Linker member selection
- Dump implib headers
- Dump relocs
- Add more info to table headers for easier grepping
2026-06-23 00:26:56 -04:00
kcbanner 224d7e7999 objdump: more coff progress 2026-06-23 00:26:56 -04:00
kcbanner 601da46f15 objdump: initial COFF implementation 2026-06-23 00:26:56 -04:00
kcbanner 6ff2b9b913 Coff: handle COMDAT sections and weak externals
- Rework object loading to handle COMDAT sections
- Add better error output for multiple definitions
- Track all symbols associated with input sections in a flat array
- Resolve weak externals to their alias if nothing defines the weak symbol
- Fixup incorrect signs of reloc addends in the logic that saves / restores them
2026-06-23 00:22:42 -04:00
kcbanner b6192adfb2 Coff: Linking input objects
- Input object validation
- Load sections, symbols, and relocs from input objects
- Load reloc addends from the reloc locations in input objects
- Flush input sections into the output
2026-06-23 00:22:42 -04:00
kcbanner 647fe54ef0 Coff: Writing relocations and symbol table 2026-06-23 00:22:41 -04:00
kcbanner f81bd30057 Coff: Symbol table output 2026-06-23 00:22:41 -04:00
kcbanner e12274f2bc - Skip the !use_llvm shared library tests on faiiling platforms
- Outputting correct linker members
2026-06-23 00:22:40 -04:00
kcbanner c8328cb57b Coff: Implement writing the export table 2026-06-23 00:21:00 -04:00
Krzysztof Wolicki 9e80795623 all: update to use new std.lang.Type definitions 2026-05-27 10:03:51 +01:00
Adrià Arrufat 02c5f05e2f std: replace usages of std.mem.indexOf with std.mem.find 2025-12-05 14:31:27 +01:00
Jacob Young 2e31077fe0 Coff: implement threadlocal variables 2025-10-10 22:47:47 -07:00
Ryan Liptak 900315a3f3 std.coff: Fix size of ImportHeader.types 2025-10-03 18:26:05 -07:00
Ryan Liptak b382119c02 std.coff: Set default values for ImportHeader sig1/sig2 fields
Just makes this a bit nicer to work with since those fields only have 1 intended value.
2025-10-03 17:44:36 -07:00
Ryan Liptak a974198b94 std.coff: Add sizeOf function to WeakExternalDefinition
Convenience function similar in nature to Symbol.sizeOf
2025-10-03 17:44:36 -07:00
Ryan Liptak 78e07b8fc8 std.coff: Fix SectionHeader.setAlignment (off by 1)
Previously, `setAlignment` would set the value to 1 fewer than it should, so if you were intending to set alignment to 8 bytes, it would actually set it to 4 bytes, etc.
2025-10-03 17:44:36 -07:00
Jacob Young e1f3fc6ce2 Coff2: create a new linker from scratch 2025-10-02 17:44:52 -04:00
mlugg b750e7cf9e change one million things 2025-09-30 13:44:49 +01:00
Andrew Kelley 79f267f6b9 std.Io: delete GenericReader
and delete deprecated alias std.io
2025-08-29 17:14:26 -07:00
Alex Rønne Petersen a69f55a7cc std.{coff,elf}: Remove the {MachineType,EM}.toTargetCpuArch() functions.
These are fundamentally incapable of producing accurate information for reasons
I've laid out in #20771. Since our only use of these functions is to check that
object files have the correct machine type, and since #21020 made
`std.Target.to{Coff,Elf}Machine()` more accurate, just switch these checks over
to that and compare the machine type tags instead.

Closes #20771.
2024-08-23 19:56:24 +02:00
Alex Rønne Petersen b01c595d4a std.coff: Capitalize MachineType.{Unknown,Thumb} for consistency. 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen ac9ca7d30c std.coff: Remove MachineType.fromTargetCpuArch().
This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen be56c67b14 std.coff: Add missing entries to MachineType.
Sources:

* https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
* https://github.com/wine-mirror/wine/blob/88a28aa5757ae74d9997b470d70216f10974247f/include/winnt.h#L2720-L2758
2024-07-24 15:02:55 -07:00
YANG Xudong 3bf0d2e516 std: Add loongarch support for coff. (#20583)
* std: Add loongarch support for coff.

See: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types

* Update toCoffMachine.
2024-07-12 00:47:32 -07:00
Jora Troosh 13070448f5 std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
Krzysztof Wolicki 815022c87b std.coff: fix setAlignment 2024-07-07 12:16:14 +02:00
Jakub Konka fb9673f208 lib/std/coff: add ImportNameType.NAME_EXPORTAS variant 2024-03-29 20:34:28 +01:00
Jakub Konka 86c4c33d2c lib/std/coff: add ImportHeader, and Relocation metadata 2024-03-22 15:12:11 +01:00
Jakub Konka 2326f0e53b lib/std/coff: add undocumented machine type ARM64EC 2024-03-22 15:05:32 +01:00
Jakub Konka 541e3a03ec lib/std/coff: allow for unhandled enum values 2024-03-22 14:04:17 +01:00
Elaine Gibson 6b38758594 coff: only store PDB basename 2024-03-14 18:56:02 -07:00
mlugg 51595d6b75 lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Andrew Kelley 3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Michal Ziulek bb2eb44430 std.coff: Fixed compile error. 2023-09-02 00:18:53 +02:00
kcbanner 8a5f331ec8 coff: handle the case of there being no PDB path 2023-08-15 10:20:11 -04:00
kcbanner 5b86180ae3 debug: support looking up debug symbols in both PDB and DWARF debug info, instead of only using DWARF if .debug_info is present
coff: support reading from memory loaded by the loader, or a mapped file
2023-08-15 10:20:11 -04:00
Zachary Raineri 49244dc0ca std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
Rohlem 7e1af51c4d std.coff: check strtab lengths against data length
Fixes illegal behavior. Invalid-length sections are now skipped in `Coff.getSectionByName`.
2023-07-27 10:21:12 -07:00
kcbanner 618b0eb3d3 dwarf: fixup integer overflow in readEhPointer
debug: handle the possibility of eh_frame / debug_frame being mapped in memory or loaded from disk
2023-07-20 22:58:16 -04:00
kcbanner f991b9dc05 debug: fix reading -gdwarf generated debug sections in COFF files
I had accidentally regressed support for -gdwarf in 461fb499f3 when I changed the logic to
use the already-mapped exe/dll image instead of loading it from disk. The string table is mapped as all zeroes by the loader,
so if a section header's name is longer than 8 bytes (like the ones generated by -gdwarf), then the name can't be read.

Now, if any section headers require the string table, the file is mapped from disk.

windows: Add NtCreateSection/NtMapViewOfSection/NtUnmapViewOfSection
2023-07-20 22:58:14 -04:00
mlugg f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov 50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Andrew Kelley aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
kcbanner 461fb499f3 windows: rework DebugInfo to use less file operations and fix some memory management issues 2023-01-08 20:28:42 -05:00
Stevie Hryciw 04f3067a79 run zig fmt on everything checked by CI 2022-11-18 19:22:42 +00:00