Skip to content

Commit 3c30e8f

Browse files
[libc] implement vdso
1 parent 62b5b61 commit 3c30e8f

File tree

14 files changed

+496
-0
lines changed

14 files changed

+496
-0
lines changed

libc/src/__support/OSUtil/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ add_object_library(
1515
DEPENDS
1616
${target_os_util}
1717
)
18+
19+
add_header_library(
20+
vdso
21+
HDRS
22+
vdso.h
23+
DEPENDS
24+
.${LIBC_TARGET_OS}.vdso
25+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//===------------- Fuchsia VDSO Header --------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FUCHSIA_VDSO_H
9+
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FUCHSIA_VDSO_H
10+
/// TODO: implement fuchsia VDSO
11+
/// https://fuchsia.dev/fuchsia-src/concepts/kernel/vdso
12+
#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FUCHSIA_VDSO_H

libc/src/__support/OSUtil/linux/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,19 @@ add_object_library(
1616
libc.src.__support.common
1717
libc.src.__support.CPP.string_view
1818
)
19+
20+
add_object_library(
21+
vdso
22+
HDRS
23+
vdso.h
24+
SRCS
25+
vdso.cpp
26+
DEPENDS
27+
.${LIBC_TARGET_ARCHITECTURE}.vdso
28+
libc.src.__support.CPP.array
29+
libc.src.__support.CPP.string_view
30+
libc.src.__support.threads.callonce
31+
libc.src.__support.threads.linux.futex_word_type
32+
libc.src.errno.errno
33+
libc.src.sys.auxv.getauxval
34+
)

libc/src/__support/OSUtil/linux/aarch64/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ add_header_library(
55
DEPENDS
66
libc.src.__support.common
77
)
8+
9+
add_header_library(
10+
vdso
11+
HDRS
12+
vdso.h
13+
DEPENDS
14+
libc.src.__support.common
15+
libc.src.__support.CPP.string_view
16+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//===---------- aarch64 vdso configuration ------------------------* C++ *-===//
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+
#include "src/__support/CPP/string_view.h"
9+
namespace LIBC_NAMESPACE {
10+
namespace vdso {
11+
// macro definitions
12+
#define LIBC_VDSO_HAS_RT_SIGRETURN
13+
#define LIBC_VDSO_HAS_GETTIMEOFDAY
14+
#define LIBC_VDSO_HAS_CLOCK_GETTIME
15+
#define LIBC_VDSO_HAS_CLOCK_GETRES
16+
17+
// list of VDSO symbols
18+
enum class VDSOSym {
19+
RTSigReturn,
20+
GetTimeOfDay,
21+
ClockGetTime,
22+
ClockGetRes,
23+
VDSOSymCount
24+
};
25+
26+
// translate VDSOSym to symbol names
27+
LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
28+
switch (sym) {
29+
case VDSOSym::RTSigReturn:
30+
return "__kernel_rt_sigreturn";
31+
case VDSOSym::GetTimeOfDay:
32+
return "__kernel_gettimeofday";
33+
case VDSOSym::ClockGetTime:
34+
return "__kernel_clock_gettime";
35+
case VDSOSym::ClockGetRes:
36+
return "__kernel_clock_getres";
37+
default:
38+
return "";
39+
}
40+
}
41+
42+
// symbol versions
43+
LIBC_INLINE constexpr cpp::string_view symbol_version(VDSOSym) {
44+
return "LINUX_2.6.39";
45+
}
46+
} // namespace vdso
47+
} // namespace LIBC_NAMESPACE

libc/src/__support/OSUtil/linux/arm/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ add_header_library(
55
DEPENDS
66
libc.src.__support.common
77
)
8+
9+
add_header_library(
10+
vdso
11+
HDRS
12+
vdso.h
13+
DEPENDS
14+
libc.src.__support.common
15+
libc.src.__support.CPP.string_view
16+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===---------- arm vdso configuration ----------------------------* C++ *-===//
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+
#include "src/__support/CPP/string_view.h"
9+
namespace LIBC_NAMESPACE {
10+
namespace vdso {
11+
// macro definitions
12+
#define LIBC_VDSO_HAS_GETTIMEOFDAY
13+
#define LIBC_VDSO_HAS_CLOCK_GETTIME
14+
15+
// list of VDSO symbols
16+
enum class VDSOSym {
17+
GetTimeOfDay,
18+
ClockGetTime,
19+
};
20+
21+
// translate VDSOSym to symbol names
22+
LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
23+
switch (sym) {
24+
case VDSOSym::GetTimeOfDay:
25+
return "__vdso_gettimeofday";
26+
case VDSOSym::ClockGetTime:
27+
return "__vdso_clock_gettime";
28+
}
29+
}
30+
31+
// symbol versions
32+
LIBC_INLINE constexpr cpp::string_view symbol_version(VDSOSym) {
33+
return "LINUX_2.6";
34+
}
35+
} // namespace vdso
36+
} // namespace LIBC_NAMESPACE

libc/src/__support/OSUtil/linux/riscv/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ add_header_library(
55
DEPENDS
66
libc.src.__support.common
77
)
8+
9+
add_header_library(
10+
vdso
11+
HDRS
12+
vdso.h
13+
DEPENDS
14+
libc.src.__support.common
15+
libc.src.__support.CPP.string_view
16+
)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//===---------- RISC-V vdso configuration -------------------------* C++ *-===//
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+
#include "src/__support/CPP/string_view.h"
9+
namespace LIBC_NAMESPACE {
10+
namespace vdso {
11+
// macro definitions
12+
#define LIBC_VDSO_HAS_RT_SIGRETURN
13+
#define LIBC_VDSO_HAS_GETTIMEOFDAY
14+
#define LIBC_VDSO_HAS_CLOCK_GETTIME
15+
#define LIBC_VDSO_HAS_CLOCK_GETRES
16+
#define LIBC_VDSO_HAS_GETCPU
17+
#define LIBC_VDSO_HAS_FLUSH_ICACHE
18+
19+
// list of VDSO symbols
20+
enum class VDSOSym {
21+
RTSigReturn,
22+
GetTimeOfDay,
23+
ClockGetTime,
24+
ClockGetRes,
25+
GetCpu,
26+
FlushICache,
27+
VDSOSymCount
28+
};
29+
30+
// translate VDSOSym to symbol names
31+
LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
32+
switch (sym) {
33+
case VDSOSym::RTSigReturn:
34+
return "__vdso_rt_sigreturn";
35+
case VDSOSym::GetTimeOfDay:
36+
return "__vdso_gettimeofday";
37+
case VDSOSym::ClockGetTime:
38+
return "__vdso_clock_gettime";
39+
case VDSOSym::ClockGetRes:
40+
return "__vdso_clock_getres";
41+
case VDSOSym::GetCpu:
42+
return "__vdso_getcpu";
43+
case VDSOSym::FlushICache:
44+
return "__vdso_flush_icache";
45+
default:
46+
return "";
47+
}
48+
}
49+
50+
// symbol versions
51+
LIBC_INLINE constexpr cpp::string_view symbol_version(VDSOSym) {
52+
return "LINUX_4.15";
53+
}
54+
} // namespace vdso
55+
} // namespace LIBC_NAMESPACE

0 commit comments

Comments
 (0)