File tree 10 files changed +150
-2
lines changed
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
2
2
libc.include.assert
3
3
libc.include.ctype
4
4
libc.include.dlfcn
5
+ libc.include.elf
5
6
libc.include.errno
6
7
libc.include.features
7
8
libc.include.fenv
8
9
libc.include.float
9
10
libc.include.stdint
10
11
libc.include.inttypes
11
12
libc.include.limits
13
+ libc.include.link
12
14
libc.include.math
13
15
libc.include.pthread
14
16
libc.include.signal
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
3
3
libc.include.ctype
4
4
libc.include.dirent
5
5
libc.include.dlfcn
6
+ libc.include.elf
6
7
libc.include.errno
7
8
libc.include.fcntl
8
9
libc.include.features
@@ -11,6 +12,7 @@ set(TARGET_PUBLIC_HEADERS
11
12
libc.include.stdint
12
13
libc.include.inttypes
13
14
libc.include.limits
15
+ libc.include.link
14
16
libc.include.math
15
17
libc.include.pthread
16
18
libc.include.sched
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ add_gen_header(
56
56
DEF_FILE dlfcn.h.def
57
57
GEN_HDR dlfcn.h
58
58
DEPENDS
59
+ .llvm-libc-types.Dl_info
59
60
.llvm-libc-macros .dlfcn_macros
60
61
.llvm_libc_common_h
61
62
)
@@ -367,6 +368,25 @@ add_gen_header(
367
368
.llvm-libc-types.posix_spawn_file_actions_t
368
369
)
369
370
371
+ add_gen_header(
372
+ link
373
+ DEF_FILE link.h.def
374
+ GEN_HDR link.h
375
+ DEPENDS
376
+ .llvm_libc_common_h
377
+ .llvm-libc-types.struct_dl_phdr_info
378
+ .llvm-libc-types.__dl_iterate_phdr_callback_t
379
+ .llvm-libc-macros .link_macros
380
+ )
381
+
382
+ add_gen_header(
383
+ elf
384
+ DEF_FILE elf.h.def
385
+ GEN_HDR elf.h
386
+ DEPENDS
387
+ .llvm-libc-macros .elf_macros
388
+ )
389
+
370
390
# TODO: Not all platforms will have a include/sys directory. Add the sys
371
391
# directory and the targets for sys/*.h files conditional to the OS requiring
372
392
# them.
Original file line number Diff line number Diff line change @@ -283,3 +283,9 @@ add_macro_header(
283
283
HDR
284
284
dlfcn-macros .h
285
285
)
286
+
287
+ add_macro_header(
288
+ elf_macros
289
+ HDR
290
+ elf-macros .h
291
+ )
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 6
6
//
7
7
//===----------------------------------------------------------------------===//
8
8
9
+ #ifndef LLVM_LIBC_MACROS_LINK_MACROS_H
10
+ #define LLVM_LIBC_MACROS_LINK_MACROS_H
11
+
12
+ #include "elf-macros.h"
13
+
9
14
#ifdef __LP64__
10
- #define ElfW (type ) Elf64_ ## type
15
+ #define ElfW (type ) Elf64_## type
11
16
#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
+
13
35
#endif
Original file line number Diff line number Diff line change @@ -89,6 +89,22 @@ add_header(thrd_t HDR thrd_t.h DEPENDS .__thread_type)
89
89
add_header(tss_t HDR tss_t.h)
90
90
add_header(tss_dtor_t HDR tss_dtor_t.h)
91
91
add_header(__atexithandler_t HDR __atexithandler_t.h)
92
+ add_header(Dl_info HDR Dl_info.h)
93
+ add_header(
94
+ __dl_iterate_phdr_callback_t
95
+ HDR __dl_iterate_phdr_callback_t.h
96
+ DEPENDS
97
+ .size_t
98
+ )
99
+ add_header(
100
+ struct_dl_phdr_info
101
+ HDR struct_dl_phdr_info.h
102
+ DEPENDS
103
+ .__dl_iterate_phdr_callback_t
104
+ .size_t
105
+ libc.include .llvm-libc-macros .link_macros
106
+ )
107
+
92
108
add_header(speed_t HDR speed_t.h)
93
109
add_header(tcflag_t HDR tcflag_t.h)
94
110
add_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