Skip to content

Commit 80c4958

Browse files
fix
1 parent 3c82e60 commit 80c4958

File tree

1 file changed

+6
-2
lines changed
  • libc/src/__support/OSUtil/linux

1 file changed

+6
-2
lines changed

libc/src/__support/OSUtil/linux/auxv.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ LIBC_INLINE void Vector::fallback_initialize_unsync() {
107107
}
108108

109109
// Attempt 2: read /proc/self/auxv.
110+
#ifdef SYS_openat
111+
int fd = syscall_impl<int>(SYS_openat, AT_FDCWD, "/proc/self/auxv",
112+
O_RDONLY | O_CLOEXEC);
113+
#else
110114
int fd = syscall_impl<int>(SYS_open, "/proc/self/auxv", O_RDONLY | O_CLOEXEC);
115+
#endif
111116
if (fd < 0) {
112117
syscall_impl<long>(SYS_munmap, vector, AUXV_MMAP_SIZE);
113118
return;
@@ -135,10 +140,9 @@ LIBC_INLINE void Vector::fallback_initialize_unsync() {
135140

136141
LIBC_INLINE cpp::optional<unsigned long> get(unsigned long type) {
137142
Vector auxvec;
138-
for (const auto &entry : auxvec) {
143+
for (const auto &entry : auxvec)
139144
if (entry.type == type)
140145
return entry.val;
141-
}
142146
return cpp::nullopt;
143147
}
144148
} // namespace auxv

0 commit comments

Comments
 (0)