File tree Expand file tree Collapse file tree 10 files changed +150
-2
lines changed Expand file tree Collapse file tree 10 files changed +150
-2
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ set(TARGET_PUBLIC_HEADERS
22 libc.include.assert
33 libc.include.ctype
44 libc.include.dlfcn
5+ libc.include.elf
56 libc.include.errno
67 libc.include.features
78 libc.include.fenv
89 libc.include.float
910 libc.include.stdint
1011 libc.include.inttypes
1112 libc.include.limits
13+ libc.include.link
1214 libc.include.math
1315 libc.include.pthread
1416 libc.include.signal
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
33 libc.include.ctype
44 libc.include.dirent
55 libc.include.dlfcn
6+ libc.include.elf
67 libc.include.errno
78 libc.include.fcntl
89 libc.include.features
@@ -11,6 +12,7 @@ set(TARGET_PUBLIC_HEADERS
1112 libc.include.stdint
1213 libc.include.inttypes
1314 libc.include.limits
15+ libc.include.link
1416 libc.include.math
1517 libc.include.pthread
1618 libc.include.sched
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ add_header_macro(
8181 dlfcn.h.def
8282 dlfcn.h
8383 DEPENDS
84+ .llvm-libc-types.Dl_info
8485 .llvm-libc-macros .dlfcn_macros
8586 .llvm_libc_common_h
8687)
@@ -420,6 +421,25 @@ add_header_macro(
420421 .llvm-libc-types.posix_spawn_file_actions_t
421422)
422423
424+ add_gen_header(
425+ link
426+ DEF_FILE link.h.def
427+ GEN_HDR link.h
428+ DEPENDS
429+ .llvm_libc_common_h
430+ .llvm-libc-types.struct_dl_phdr_info
431+ .llvm-libc-types.__dl_iterate_phdr_callback_t
432+ .llvm-libc-macros .link_macros
433+ )
434+
435+ add_gen_header(
436+ elf
437+ DEF_FILE elf.h.def
438+ GEN_HDR elf.h
439+ DEPENDS
440+ .llvm-libc-macros .elf_macros
441+ )
442+
423443# TODO: Not all platforms will have a include/sys directory. Add the sys
424444# directory and the targets for sys/*.h files conditional to the OS requiring
425445# them.
Original file line number Diff line number Diff line change @@ -289,3 +289,9 @@ add_macro_header(
289289 HDR
290290 dlfcn-macros .h
291291)
292+
293+ add_macro_header(
294+ elf_macros
295+ HDR
296+ elf-macros .h
297+ )
Original file line number Diff line number Diff line change 1+ //===-- Definition of macros from elf.h -----------------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ //===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_MACROS_ELF_MACROS_H
10+ #define LLVM_LIBC_MACROS_ELF_MACROS_H
11+
12+ #if __has_include (< linux /elf .h > )
13+ #include <linux/elf.h>
14+ #else
15+ #error "cannot use <sys/elf.h> without proper system headers."
16+ #endif
17+
18+ #endif // LLVM_LIBC_MACROS_ELF_MACROS_H
Original file line number Diff line number Diff line change 66//
77//===----------------------------------------------------------------------===//
88
9+ #ifndef LLVM_LIBC_MACROS_LINK_MACROS_H
10+ #define LLVM_LIBC_MACROS_LINK_MACROS_H
11+
12+ #include "elf-macros.h"
13+
914#ifdef __LP64__
10- #define ElfW (type ) Elf64_ ## type
15+ #define ElfW (type ) Elf64_## type
1116#else
12- #define ElfW (type ) Elf32_ ## type
17+ #define ElfW (type ) Elf32_##type
18+ #endif
19+
20+ struct link_map {
21+ ElfW (Addr ) l_addr ;
22+ char * l_name ;
23+ ElfW (Dyn ) * l_ld ;
24+ struct link_map * l_next , * l_prev ;
25+ };
26+
27+ struct r_debug {
28+ int r_version ;
29+ struct link_map * r_map ;
30+ ElfW (Addr ) r_brk ;
31+ enum { RT_CONSISTENT , RT_ADD , RT_DELETE } r_state ;
32+ ElfW (Addr ) r_ldbase ;
33+ };
34+
1335#endif
Original file line number Diff line number Diff line change @@ -94,6 +94,22 @@ add_header(thrd_t HDR thrd_t.h DEPENDS .__thread_type)
9494add_header(tss_t HDR tss_t.h)
9595add_header(tss_dtor_t HDR tss_dtor_t.h)
9696add_header(__atexithandler_t HDR __atexithandler_t.h)
97+ add_header(Dl_info HDR Dl_info.h)
98+ add_header(
99+ __dl_iterate_phdr_callback_t
100+ HDR __dl_iterate_phdr_callback_t.h
101+ DEPENDS
102+ .size_t
103+ )
104+ add_header(
105+ struct_dl_phdr_info
106+ HDR struct_dl_phdr_info.h
107+ DEPENDS
108+ .__dl_iterate_phdr_callback_t
109+ .size_t
110+ libc.include .llvm-libc-macros .link_macros
111+ )
112+
97113add_header(speed_t HDR speed_t.h)
98114add_header(tcflag_t HDR tcflag_t.h)
99115add_header(struct_termios HDR struct_termios.h DEPENDS .cc_t .speed_t .tcflag_t)
Original file line number Diff line number Diff line change 1+ //===-- Definition of type Dl_info ----------------------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ //===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_TYPES_DL_INFO_H
10+ #define LLVM_LIBC_TYPES_DL_INFO_H
11+
12+ typedef struct {
13+ const char * dli_fname ;
14+ void * dli_fbase ;
15+ const char * dli_sname ;
16+ void * dli_saddr ;
17+ } Dl_info ;
18+
19+ #endif // LLVM_LIBC_TYPES_DL_INFO_H
Original file line number Diff line number Diff line change 1+ //===-- Definition of __dl_iterate_phdr_callback_t type -------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ //===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_TYPES___DL_ITERATE_PHDR_CALLBACK_T_H
10+ #define LLVM_LIBC_TYPES___DL_ITERATE_PHDR_CALLBACK_T_H
11+
12+ #include "llvm-libc-types/size_t.h"
13+
14+ typedef int (* __dl_iterate_phdr_callback_t )(struct dl_phdr_info * info ,
15+ size_t size , void * data );
16+
17+ #endif // LLVM_LIBC_TYPES___DL_ITERATE_PHDR_CALLBACK_T_H
Original file line number Diff line number Diff line change 1+ //===-- Definition of type struct dl_phdr_info ----------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ //===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_TYPES_STRUCT_DL_PHDR_INFO_H
10+ #define LLVM_LIBC_TYPES_STRUCT_DL_PHDR_INFO_H
11+
12+ #include "llvm-libc-macros/link-macros.h"
13+ #include "llvm-libc-types/size_t.h"
14+
15+ struct dl_phdr_info {
16+ ElfW (Addr ) dlpi_addr ;
17+ const char * dlpi_name ;
18+ const ElfW (Phdr ) * dlpi_phdr ;
19+ ElfW (Half ) dlpi_phnum ;
20+ unsigned long long int dlpi_adds ;
21+ unsigned long long int dlpi_subs ;
22+ size_t dlpi_tls_modid ;
23+ void * dlpi_tls_data ;
24+ };
25+
26+ #endif // LLVM_LIBC_TYPES_STRUCT_DL_PHDR_INFO_H
You can’t perform that action at this time.
0 commit comments