mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Add <link.h> for absl
This commit is contained in:
parent
a11016e590
commit
8874a37abc
5 changed files with 99 additions and 0 deletions
|
@ -752,6 +752,8 @@ ape_loader_end:
|
|||
#if SupportsSystemv() || SupportsMetal()
|
||||
.section .elf.phdrs,"a",@progbits
|
||||
|
||||
.globl ape_phdrs
|
||||
ape_phdrs:
|
||||
.long PT_LOAD
|
||||
.long PF_R|PF_X
|
||||
.stub ape_cod_offset,quad
|
||||
|
|
|
@ -22,6 +22,7 @@ extern uint8_t __data_start[] __attribute__((__weak__));
|
|||
extern uint8_t __data_end[] __attribute__((__weak__));
|
||||
extern uint8_t __bss_start[] __attribute__((__weak__));
|
||||
extern uint8_t __bss_end[] __attribute__((__weak__));
|
||||
extern unsigned char ape_phdrs[] __attribute__((__weak__));
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_ */
|
||||
|
|
33
libc/calls/dl_iterate_phdr.c
Normal file
33
libc/calls/dl_iterate_phdr.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/elf/link.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
int dl_iterate_phdr(int callback(struct dl_phdr_info *info, size_t size,
|
||||
void *data),
|
||||
void *data) {
|
||||
struct dl_phdr_info info = {
|
||||
.dlpi_addr = (uintptr_t)__executable_start,
|
||||
.dlpi_name = GetProgramExecutableName(),
|
||||
.dlpi_phdr = (const Elf64_Phdr *)ape_phdrs,
|
||||
.dlpi_phnum = 3,
|
||||
};
|
||||
return callback(&info, sizeof(info), data);
|
||||
}
|
40
libc/elf/link.h
Normal file
40
libc/elf/link.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef COSMOPOLITAN_ELF_LINK_H_
|
||||
#define COSMOPOLITAN_ELF_LINK_H_
|
||||
#include "libc/elf/scalar.h"
|
||||
#include "libc/elf/struct/dyn.h"
|
||||
#include "libc/elf/struct/phdr.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define ElfW(type) Elf64_##type
|
||||
|
||||
struct dl_phdr_info {
|
||||
Elf64_Addr dlpi_addr;
|
||||
const char *dlpi_name;
|
||||
const Elf64_Phdr *dlpi_phdr;
|
||||
Elf64_Half dlpi_phnum;
|
||||
unsigned long long int dlpi_adds;
|
||||
unsigned long long int dlpi_subs;
|
||||
size_t dlpi_tls_modid;
|
||||
void *dlpi_tls_data;
|
||||
};
|
||||
|
||||
struct link_map {
|
||||
Elf64_Addr l_addr;
|
||||
char *l_name;
|
||||
Elf64_Dyn *l_ld;
|
||||
struct link_map *l_next;
|
||||
struct link_map *l_prev;
|
||||
};
|
||||
|
||||
struct r_debug {
|
||||
int r_version;
|
||||
struct link_map *r_map;
|
||||
Elf64_Addr r_brk;
|
||||
enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
|
||||
Elf64_Addr r_ldbase;
|
||||
};
|
||||
|
||||
int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_ELF_LINK_H_ */
|
23
libc/isystem/link.h
Normal file
23
libc/isystem/link.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef _LINK_H
|
||||
#define _LINK_H
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/link.h"
|
||||
#include "libc/elf/scalar.h"
|
||||
#include "libc/elf/struct/auxv.h"
|
||||
#include "libc/elf/struct/chdr.h"
|
||||
#include "libc/elf/struct/dyn.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
#include "libc/elf/struct/lib.h"
|
||||
#include "libc/elf/struct/move.h"
|
||||
#include "libc/elf/struct/nhdr.h"
|
||||
#include "libc/elf/struct/phdr.h"
|
||||
#include "libc/elf/struct/rel.h"
|
||||
#include "libc/elf/struct/rela.h"
|
||||
#include "libc/elf/struct/shdr.h"
|
||||
#include "libc/elf/struct/sym.h"
|
||||
#include "libc/elf/struct/syminfo.h"
|
||||
#include "libc/elf/struct/verdaux.h"
|
||||
#include "libc/elf/struct/verdef.h"
|
||||
#include "libc/elf/struct/vernaux.h"
|
||||
#include "libc/elf/struct/verneed.h"
|
||||
#endif /* _LINK_H */
|
Loading…
Reference in a new issue