Commit Graph

87 Commits

Author SHA1 Message Date
Jakub Konka
ace1a69a55 elf: add new R_RISCV_TLSDESC reloc type 2024-02-17 11:41:18 +01:00
Jakub Konka
975862aca9 elf: add riscv dynamic relocs 2024-02-17 11:29:06 +01:00
Jakub Konka
5122a3d2d9 lib/std/elf: use enums for relocs 2024-02-17 08:50:53 +01:00
Jakub Konka
70a5dca13e elf: add riscv reloc types 2024-02-17 08:45:42 +01:00
Jakub Konka
0c3d5fd1fe lib/std/elf: add aarch64 relocation kinds 2024-02-14 23:39:20 +01:00
Jakub Konka
acd7cbf0b5 elf: init output COMDAT group sections 2023-11-09 17:41:14 +01:00
Jakub Konka
261db02018 CheckObject: support parsing and dumping archive symtab for ELF 2023-11-06 21:18:26 +01: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
Andrew Kelley
5aa82ed477 std.elf: remove some unneeded @as 2023-10-21 21:38:41 -04:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
kcbanner
ea9917d9bd debug: support loading elf debug info from external files
Some distributions (ie. Ubuntu) have their libc debug
info in separate files. This change allows the stack walking
code to read that debug info.

- add support for reading compressed ELF sections
- support reading the build-id from the elf headers in order to lookup external debug info
- support reading the .gnu_debuglink section to look up external debug info
2023-07-20 22:58:12 -04:00
Jakub Konka
0627ca527a elf: add ELF and GNU-specific missing defs 2023-07-13 15:08:01 +02: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
Andrew Kelley
a72d634b73
Merge pull request #16046 from BratishkaErik/issue-6128
Renaming `@xtoy` to `@YfromX`
2023-06-19 22:36:24 -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
Xavier Bouchoux
c39191a086 objcopy: add support for --compress-debug-sections 2023-06-19 08:51:03 +02:00
Jakub Konka
49c1384bac elf: fix typo in def of SHT_LLVM_ADDRSIG 2023-05-07 09:09:19 +02:00
Jakub Konka
66ff7d9161 elf: add more missing defs for SHT_* and SHF_* 2023-05-07 09:05:18 +02:00
Jakub Konka
b95cdf0aeb elf: add helpers for extracting type and bind from symbol def 2023-04-23 13:50:24 +02:00
Jakub Konka
c3ce04b9e5 elf: add missing doc comments to some definitions 2023-04-23 13:24:59 +02:00
Stevie Hryciw
04f3067a79 run zig fmt on everything checked by CI 2022-11-18 19:22:42 +00:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
Andrew Kelley
7453f56e67 stage2: explicitly tagged enums no longer have one possible value
Previously, Zig had inconsistent semantics for an enum like this:

`enum(u8){zero = 0}`

Although in theory this can only hold one possible value, the tag
`zero`, Zig no longer will treat the type this way. It will do loads and
stores, as if the type has runtime bits.

Closes #12619

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-24 22:20:31 -07:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
r00ster91
bb55276f06 Avoid some unnecessary underscores in constant names 2022-05-02 15:29:04 -04:00
Veikka Tuominen
6d48600ea0
Merge pull request #10717 from gh-fork-dump/seccomp-bits
Add Seccomp bits for linux
2022-04-28 18:54:09 +03:00
Tom Read Cutting
cdcb34cdf4
Pull elf magic string out to re-used constant 2022-04-04 15:33:24 +03:00
Tom Maenan Read Cutting
9bb19a090e std: Add elf.EM, coff.MachineType to Target.CPU.Arch conversions
target.Arch already supports finding the correct encoding for either
target, so being able to do the inverse has use cases for when parsing
files of an unknown target (i.e. for zar).
2022-03-15 13:48:42 -04:00
Stephen Gregoratto
a49f2d9f8d Add bits for the Linux Auditing System
Also adds the _CSKY and _FRV ELF machines that are defined in
`<linux/elf-em.h>`
2022-01-29 13:57:14 +11:00
John Schmidt
63ee6e6625 Rename mem.bswapAllFields to byteSwapAllFields
To match the renaming of `@bswap` to `@byteSwap` in
1fdb24827f.
2022-01-28 21:03:21 -05:00
ominitay
2e887452d5 Fix dead link 2021-12-21 17:13:52 -08:00
Andrew Kelley
808b9239a3 improve musl dynamic stubs file libc.s
tools/gen_stubs.zig now cuts out the middle man and operates directly on
the libc.so ELF file. it outputs accurate .size directives for objects.

std.elf gains an STV enum.
2021-12-08 22:32:31 -07:00
Jakub Konka
2a0c44fff3 elf: add amd64 relocation types
I believe these are Linux specific so they will need to be os-gated
in `elf.zig` at some point, but I reckon it should be fine to have
them as-is right now since the ELF linker work will mainly be done
on x86-64 Linux at first.
2021-09-19 14:02:22 +02:00
Jakub Konka
d8375696f6 elf: add a couple missing special section indexes SHN_ 2021-09-17 12:12:50 +02:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Tom Maenan Read Cutting
177b1b6bf9 Add fat/universal dylib support to zig ld
With this change zig ld can link with dynamic libraries
contained within a fat/universal file that had multiple
seperate binaries embedded within it for multi-arch
support (in macOS).

Whilst zig can still only create single-architecture
executables - the ability to link with fat libraries is
useful for cases where they are the easiest (or only)
option to link against.
2021-06-25 08:38:47 +02:00
ArtixFox
032204ffe7
Changed return values of SectionHeaderIterator().next() to bswapAllFields() (#9014) 2021-06-08 20:32:12 +03:00
Isaac Freund
5b850d5c92
Run zig fmt on src/ and lib/std/
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-20 17:14:18 +02:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
7dd33d4316 stage2: fix compile errors in test harness 2021-05-06 17:48:38 -07:00
Andrew Kelley
507a8096d2 std: fix compile errors caught by stage2 AstGen
* `comptime const` is redundant
 * don't use `extern enum`; specify a tag type.
   `extern enum` is only when you need tags to alias. But aliasing tags
   is a smell. I will be making a proposal shortly to remove `extern enum`
   from the language.
 * there is no such thing as `packed enum`.
 * instead of `catch |_|`, omit the capture entirely.
 * unused function definition with missing parameter name
 * using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
Asherah Connor
24e5959840 elf: make EM non-exhaustive 2021-03-11 10:09:51 +11:00
Asherah Connor
c5eb15526d expose machine field in ELF header 2021-03-10 16:26:41 +11:00
jacob gw
5d215cc76b stage2 Elf linker: fill in bswapAllFields
I moved it to std.elf since it could be used there and added test
2021-03-07 23:18:26 +02:00
Andrew Kelley
ffb2568a9f
Merge pull request #7763 from kivikakk/zig-elf-parse
std.elf: expose parsing decoupled from std.fs.File
2021-03-04 11:56:31 -08:00
Tadeo Kondrak
5dfe0e7e8f
Convert inline fn to callconv(.Inline) everywhere 2021-02-10 20:06:12 -07:00
Asherah Connor
affb57aad9 use interfaces 2021-01-15 10:34:53 +11:00