aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-01-29 00:08:01 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-01-29 12:05:36 -0500
commit1ba455485519001f23f9ea8c5b7e02b334f6d019 (patch)
treed3cb27442e56f9d57e0360c4a1e009ac9d8ed78a /lib/std/os/linux.zig
parent3ec37c979ec6ad3e375b391791dff2fbc0a7dddf (diff)
downloadzig-1ba455485519001f23f9ea8c5b7e02b334f6d019.tar.gz
zig-1ba455485519001f23f9ea8c5b7e02b334f6d019.zip
Correct dl_iterate_phdr address
The base should be zero so that p_vaddr + dlpi_addr = p_vaddr
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig57
1 files changed, 0 insertions, 57 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index fcc1e62489..5c25b4369c 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -1041,63 +1041,6 @@ pub fn uname(uts: *utsname) usize {
return syscall1(SYS_uname, @ptrToInt(uts));
}
-// XXX: This should be weak
-extern const __ehdr_start: elf.Ehdr;
-
-pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_info, size: usize, data: ?*T) i32, data: ?*T) isize {
- if (builtin.link_libc) {
- return std.c.dl_iterate_phdr(@ptrCast(std.c.dl_iterate_phdr_callback, callback), @ptrCast(?*c_void, data));
- }
-
- const elf_base = @ptrToInt(&__ehdr_start);
- const n_phdr = __ehdr_start.e_phnum;
- const phdrs = (@intToPtr([*]elf.Phdr, elf_base + __ehdr_start.e_phoff))[0..n_phdr];
-
- var it = dl.linkmap_iterator(phdrs) catch return 0;
-
- // The executable has no dynamic link segment, create a single entry for
- // the whole ELF image
- if (it.end()) {
- var info = dl_phdr_info{
- .dlpi_addr = elf_base,
- .dlpi_name = "/proc/self/exe",
- .dlpi_phdr = @intToPtr([*]elf.Phdr, elf_base + __ehdr_start.e_phoff),
- .dlpi_phnum = __ehdr_start.e_phnum,
- };
-
- return callback(&info, @sizeOf(dl_phdr_info), data);
- }
-
- // Last return value from the callback function
- var last_r: isize = 0;
- while (it.next()) |entry| {
- var dlpi_phdr: usize = undefined;
- var dlpi_phnum: u16 = undefined;
-
- if (entry.l_addr != 0) {
- const elf_header = @intToPtr(*elf.Ehdr, entry.l_addr);
- dlpi_phdr = entry.l_addr + elf_header.e_phoff;
- dlpi_phnum = elf_header.e_phnum;
- } else {
- // This is the running ELF image
- dlpi_phdr = elf_base + __ehdr_start.e_phoff;
- dlpi_phnum = __ehdr_start.e_phnum;
- }
-
- var info = dl_phdr_info{
- .dlpi_addr = entry.l_addr,
- .dlpi_name = entry.l_name,
- .dlpi_phdr = @intToPtr([*]elf.Phdr, dlpi_phdr),
- .dlpi_phnum = dlpi_phnum,
- };
-
- last_r = callback(&info, @sizeOf(dl_phdr_info), data);
- if (last_r != 0) break;
- }
-
- return last_r;
-}
-
pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize {
return syscall2(SYS_io_uring_setup, entries, @ptrToInt(p));
}