Skip to content

Commit 4371c79

Browse files
[libc] Reapply ELF/LINK header changes (#102765)
This is based on @izaakschroeder previous patch but I only select macro definitions for now. We need these definitions for VDSO work, which has been delayed for a very long time. Co-authored-by: Izaak Schroeder <[email protected]>
1 parent b89853b commit 4371c79

File tree

10 files changed

+104
-2
lines changed

10 files changed

+104
-2
lines changed

libc/config/linux/aarch64/headers.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

libc/config/linux/x86_64/headers.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

libc/include/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,23 @@ add_header_macro(
420420
.llvm-libc-types.posix_spawn_file_actions_t
421421
)
422422

423+
add_gen_header(
424+
link
425+
DEF_FILE link.h.def
426+
GEN_HDR link.h
427+
DEPENDS
428+
.llvm_libc_common_h
429+
.llvm-libc-macros.link_macros
430+
)
431+
432+
add_gen_header(
433+
elf
434+
DEF_FILE elf.h.def
435+
GEN_HDR elf.h
436+
DEPENDS
437+
.llvm-libc-macros.elf_macros
438+
)
439+
423440
# TODO: Not all platforms will have a include/sys directory. Add the sys
424441
# directory and the targets for sys/*.h files conditional to the OS requiring
425442
# them.

libc/include/elf.h.def

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- System V header 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_ELF_H
10+
#define LLVM_LIBC_ELF_H
11+
12+
#include "__llvm-libc-common.h"
13+
#include "llvm-libc-macros/elf-macros.h"
14+
15+
%%public_api()
16+
17+
#endif // LLVM_LIBC_ELF_H

libc/include/link.h.def

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- GNU header link.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_LINK_H
10+
#define LLVM_LIBC_LINK_H
11+
12+
#include "__llvm-libc-common.h"
13+
#include "llvm-libc-macros/link-macros.h"
14+
15+
%%public_api()
16+
17+
#endif // LLVM_LIBC_LINK_H

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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

libc/include/llvm-libc-macros/link-macros.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
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+
1320
#endif

libc/newhdrgen/yaml/elf.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
header: elf.h
2+
standards:
3+
- Linux
4+
macros: []
5+
types: []
6+
enums: []
7+
objects: []
8+
functions: []

libc/newhdrgen/yaml/link.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
header: link.h
2+
standards:
3+
- Linux
4+
macros: []
5+
types: []
6+
enums: []
7+
objects: []
8+
functions: []

0 commit comments

Comments
 (0)