File tree Expand file tree Collapse file tree 4 files changed +26
-28
lines changed Expand file tree Collapse file tree 4 files changed +26
-28
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,21 @@ typedef uintptr_t ArgcType;
49
49
typedef uintptr_t ArgVEntryType;
50
50
51
51
typedef uintptr_t EnvironType;
52
- typedef uintptr_t AuxEntryType;
53
52
#else
54
53
#error "argc and argv types are not defined for the target platform."
55
54
#endif
56
55
56
+ // Linux manpage on `proc(5)` says that the aux vector is an array of
57
+ // unsigned long pairs.
58
+ // (see: https://man7.org/linux/man-pages/man5/proc.5.html)
59
+ using AuxEntryType = unsigned long ;
60
+ // Using the naming convention from `proc(5)`.
61
+ // TODO: Would be nice to use the aux entry structure from elf.h when available.
62
+ struct AuxEntry {
63
+ AuxEntryType id;
64
+ AuxEntryType value;
65
+ };
66
+
57
67
struct Args {
58
68
ArgcType argc;
59
69
@@ -78,6 +88,9 @@ struct AppProperties {
78
88
79
89
// Environment data.
80
90
EnvironType *env_ptr;
91
+
92
+ // Auxiliary vector data.
93
+ AuxEntry *auxv_ptr;
81
94
};
82
95
83
96
extern AppProperties app;
Original file line number Diff line number Diff line change @@ -126,12 +126,7 @@ static void call_fini_array_callbacks() {
126
126
} // namespace LIBC_NAMESPACE
127
127
128
128
using LIBC_NAMESPACE::app;
129
-
130
- // TODO: Would be nice to use the aux entry structure from elf.h when available.
131
- struct AuxEntry {
132
- uint64_t type;
133
- uint64_t value;
134
- };
129
+ using LIBC_NAMESPACE::AuxEntry;
135
130
136
131
__attribute__ ((noinline)) static void do_start() {
137
132
auto tid = LIBC_NAMESPACE::syscall_impl<long >(SYS_gettid);
@@ -155,9 +150,9 @@ __attribute__((noinline)) static void do_start() {
155
150
// denoted by an AT_NULL entry.
156
151
Elf64_Phdr *program_hdr_table = nullptr ;
157
152
uintptr_t program_hdr_count;
158
- for (AuxEntry *aux_entry = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
159
- aux_entry->type != AT_NULL; ++aux_entry) {
160
- switch (aux_entry->type ) {
153
+ app. auxv_ptr = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
154
+ for ( auto *aux_entry = app. auxv_ptr ; aux_entry->id != AT_NULL; ++aux_entry) {
155
+ switch (aux_entry->id ) {
161
156
case AT_PHDR:
162
157
program_hdr_table = reinterpret_cast <Elf64_Phdr *>(aux_entry->value );
163
158
break ;
Original file line number Diff line number Diff line change @@ -115,12 +115,7 @@ static void call_fini_array_callbacks() {
115
115
} // namespace LIBC_NAMESPACE
116
116
117
117
using LIBC_NAMESPACE::app;
118
-
119
- // TODO: Would be nice to use the aux entry structure from elf.h when available.
120
- struct AuxEntry {
121
- LIBC_NAMESPACE::AuxEntryType type;
122
- LIBC_NAMESPACE::AuxEntryType value;
123
- };
118
+ using LIBC_NAMESPACE::AuxEntry;
124
119
125
120
#if defined(LIBC_TARGET_ARCH_IS_X86_64) || \
126
121
defined (LIBC_TARGET_ARCH_IS_AARCH64) || \
@@ -158,9 +153,9 @@ __attribute__((noinline)) static void do_start() {
158
153
// denoted by an AT_NULL entry.
159
154
PgrHdrTableType *program_hdr_table = nullptr ;
160
155
uintptr_t program_hdr_count;
161
- for (AuxEntry *aux_entry = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
162
- aux_entry->type != AT_NULL; ++aux_entry) {
163
- switch (aux_entry->type ) {
156
+ app. auxv_ptr = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
157
+ for ( auto *aux_entry = app. auxv_ptr ; aux_entry->id != AT_NULL; ++aux_entry) {
158
+ switch (aux_entry->id ) {
164
159
case AT_PHDR:
165
160
program_hdr_table = reinterpret_cast <PgrHdrTableType *>(aux_entry->value );
166
161
break ;
Original file line number Diff line number Diff line change @@ -144,12 +144,7 @@ static void call_fini_array_callbacks() {
144
144
} // namespace LIBC_NAMESPACE
145
145
146
146
using LIBC_NAMESPACE::app;
147
-
148
- // TODO: Would be nice to use the aux entry structure from elf.h when available.
149
- struct AuxEntry {
150
- uint64_t type;
151
- uint64_t value;
152
- };
147
+ using LIBC_NAMESPACE::AuxEntry;
153
148
154
149
extern " C" void _start () {
155
150
// This TU is compiled with -fno-omit-frame-pointer. Hence, the previous value
@@ -193,9 +188,9 @@ extern "C" void _start() {
193
188
// denoted by an AT_NULL entry.
194
189
Elf64_Phdr *program_hdr_table = nullptr ;
195
190
uintptr_t program_hdr_count = 0 ;
196
- for (AuxEntry *aux_entry = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
197
- aux_entry->type != AT_NULL; ++aux_entry) {
198
- switch (aux_entry->type ) {
191
+ app. auxv_ptr = reinterpret_cast <AuxEntry *>(env_end_marker + 1 );
192
+ for ( auto *aux_entry = app. auxv_ptr ; aux_entry->id != AT_NULL; ++aux_entry) {
193
+ switch (aux_entry->id ) {
199
194
case AT_PHDR:
200
195
program_hdr_table = reinterpret_cast <Elf64_Phdr *>(aux_entry->value );
201
196
break ;
You can’t perform that action at this time.
0 commit comments