[libc-commits] [clang] [libc] [libc] Provide a minimal implementation of elf.h (PR #172766)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Mon Dec 22 22:35:58 PST 2025


https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/172766

>From a9f43d99712ca1780d03ddde3a9006ab2ee06cdb Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Wed, 17 Dec 2025 19:27:16 +0000
Subject: [PATCH 1/9] [libc] Provide a minimal implementation of elf.h

Some of the baremetal users of libc use elf.h to generate coredumps and
we would like to support this use case without needing Linux elf.h.

We plan to expand the implementation in the future.
---
 libc/config/baremetal/aarch64/headers.txt   |   1 +
 libc/config/baremetal/arm/headers.txt       |   1 +
 libc/config/baremetal/riscv/headers.txt     |   1 +
 libc/include/elf.yaml                       | 162 +++++++++++++++++++-
 libc/include/llvm-libc-macros/elf-macros.h  |   6 +-
 libc/include/llvm-libc-types/Elf32_Addr.h   |  16 ++
 libc/include/llvm-libc-types/Elf32_Ehdr.h   |  35 +++++
 libc/include/llvm-libc-types/Elf32_Half.h   |  16 ++
 libc/include/llvm-libc-types/Elf32_Lword.h  |  16 ++
 libc/include/llvm-libc-types/Elf32_Nhdr.h   |  20 +++
 libc/include/llvm-libc-types/Elf32_Off.h    |  16 ++
 libc/include/llvm-libc-types/Elf32_Phdr.h   |  27 ++++
 libc/include/llvm-libc-types/Elf32_Sword.h  |  16 ++
 libc/include/llvm-libc-types/Elf32_Word.h   |  16 ++
 libc/include/llvm-libc-types/Elf64_Addr.h   |  16 ++
 libc/include/llvm-libc-types/Elf64_Ehdr.h   |  35 +++++
 libc/include/llvm-libc-types/Elf64_Half.h   |  16 ++
 libc/include/llvm-libc-types/Elf64_Lword.h  |  16 ++
 libc/include/llvm-libc-types/Elf64_Nhdr.h   |  20 +++
 libc/include/llvm-libc-types/Elf64_Off.h    |  16 ++
 libc/include/llvm-libc-types/Elf64_Phdr.h   |  28 ++++
 libc/include/llvm-libc-types/Elf64_Sword.h  |  16 ++
 libc/include/llvm-libc-types/Elf64_Sxword.h |  16 ++
 libc/include/llvm-libc-types/Elf64_Word.h   |  16 ++
 libc/include/llvm-libc-types/Elf64_Xword.h  |  16 ++
 25 files changed, 552 insertions(+), 8 deletions(-)
 create mode 100644 libc/include/llvm-libc-types/Elf32_Addr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Ehdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Half.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Lword.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Nhdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Off.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Phdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Sword.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Word.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Addr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Ehdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Half.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Lword.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Nhdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Off.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Phdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Sword.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Sxword.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Word.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Xword.h

diff --git a/libc/config/baremetal/aarch64/headers.txt b/libc/config/baremetal/aarch64/headers.txt
index 5666ef7e0012d..31cc04d849109 100644
--- a/libc/config/baremetal/aarch64/headers.txt
+++ b/libc/config/baremetal/aarch64/headers.txt
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.complex
     libc.include.ctype
+    libc.include.elf
     libc.include.errno
     libc.include.features
     libc.include.fenv
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 1f64afebdaaa7..a259c3a4d834b 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.complex
     libc.include.ctype
+    libc.include.elf
     libc.include.errno
     libc.include.features
     libc.include.fenv
diff --git a/libc/config/baremetal/riscv/headers.txt b/libc/config/baremetal/riscv/headers.txt
index 1f64afebdaaa7..a259c3a4d834b 100644
--- a/libc/config/baremetal/riscv/headers.txt
+++ b/libc/config/baremetal/riscv/headers.txt
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.assert
     libc.include.complex
     libc.include.ctype
+    libc.include.elf
     libc.include.errno
     libc.include.features
     libc.include.fenv
diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index f78ae82c77850..c433b9d495c9c 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -1,9 +1,165 @@
 header: elf.h
 header_template: elf.h.def
 standards:
-  - Linux
-macros: []
-types: []
+  - svid
+macros:
+  - macro_name: EI_MAG0
+    macro_value: 0
+  - macro_name: EI_MAG1
+    macro_value: 1
+  - macro_name: EI_MAG2
+    macro_value: 2
+  - macro_name: EI_MAG3
+    macro_value: 3
+  - macro_name: EI_CLASS
+    macro_value: 4
+  - macro_name: EI_DATA
+    macro_value: 5
+  - macro_name: EI_VERSION
+    macro_value: 6
+  - macro_name: EI_OSABI
+    macro_value: 7
+  - macro_name: EI_ABIVERSION
+    macro_value: 8
+  - macro_name: EI_PAD
+    macro_value: 9
+  - macro_name: EI_NIDENT
+    macro_value: 16
+  - macro_name: ELFMAG0
+    macro_value: '0x7f'
+  - macro_name: ELFMAG1
+    macro_value: "'E'"
+  - macro_name: ELFMAG2
+    macro_value: "'L'"
+  - macro_name: ELFMAG3
+    macro_value: "'F'"
+  - macro_name: ELFMAG
+    macro_value: '"\177ELF"'
+  - macro_name: SELFMAG
+    macro_value: 4
+  - macro_name: ELFCLASSNONE
+    macro_value: 0
+  - macro_name: ELFCLASS32
+    macro_value: 1
+  - macro_name: ELFCLASS64
+    macro_value: 2
+  - macro_name: ELFDATANONE
+    macro_value: 0
+  - macro_name: ELFDATA2LSB
+    macro_value: 1
+  - macro_name: ELFDATA2MSB
+    macro_value: 2
+  - macro_name: ELFOSABI_NONE
+    macro_value: 0
+  - macro_name: ET_NONE
+    macro_value: 0
+  - macro_name: ET_REL
+    macro_value: 1
+  - macro_name: ET_EXEC
+    macro_value: 2
+  - macro_name: ET_DYN
+    macro_value: 3
+  - macro_name: ET_CORE
+    macro_value: 4
+  - macro_name: ET_LOOS
+    macro_value: '0xfe00'
+  - macro_name: ET_HIOS
+    macro_value: '0xfeff'
+  - macro_name: ET_LOPROC
+    macro_value: '0xff00'
+  - macro_name: ET_HIPROC
+    macro_value: '0xffff'
+  - macro_name: EM_NONE
+    macro_value: 0
+  - macro_name: EV_NONE
+    macro_value: 0
+  - macro_name: EV_CURRENT
+    macro_value: 1
+  - macro_name: PT_NULL
+    macro_value: 0
+  - macro_name: PT_LOAD
+    macro_value: 1
+  - macro_name: PT_DYNAMIC
+    macro_value: 2
+  - macro_name: PT_INTERP
+    macro_value: 3
+  - macro_name: PT_NOTE
+    macro_value: 4
+  - macro_name: PT_SHLIB
+    macro_value: 5
+  - macro_name: PT_PHDR
+    macro_value: 6
+  - macro_name: PT_TLS
+    macro_value: 7
+  - macro_name: PT_LOOS
+    macro_value: '0x60000000'
+  - macro_name: PT_HIOS
+    macro_value: '0x6fffffff'
+  - macro_name: PT_LOPROC
+    macro_value: '0x70000000'
+  - macro_name: PT_HIPROC
+    macro_value: '0x7fffffff'
+  - macro_name: PF_X
+    macro_value: '0x1'
+  - macro_name: PF_W
+    macro_value: '0x2'
+  - macro_name: PF_R
+    macro_value: '0x4'
+  - macro_name: PF_MASKOS
+    macro_value: '0x0ff00000'
+  - macro_name: PF_MASKPROC
+    macro_value: '0xf0000000'
+  # Notes used in ET_CORE.
+  - macro_name: NT_PRSTATUS
+    macro_value: 1
+    standards:
+      - linux
+  - macro_name: NT_PRFPREG
+    macro_value: 2
+    standards:
+      - linux
+  - macro_name: NT_PRPSINFO
+    macro_value: 3
+    standards:
+      - linux
+  - macro_name: NT_TASKSTRUCT
+    macro_value: 4
+    standards:
+      - linux
+  - macro_name: NT_PLATFORM
+    macro_value: 5
+    standards:
+      - linux
+  - macro_name: NT_AUXV
+    macro_value: 6
+    standards:
+      - linux
+  # Notes used by GNU toolchain.
+  - macro_name: NT_GNU_BUILD_ID
+    macro_value: 3
+    standards:
+      - gnu
+types:
+  - type_name: Elf32_Addr
+  - type_name: Elf32_Half
+  - type_name: Elf32_Off
+  - type_name: Elf32_Sword
+  - type_name: Elf32_Word
+  - type_name: Elf32_Lword
+  - type_name: Elf32_Ehdr
+  - type_name: Elf32_Phdr
+  - type_name: Elf32_Nhdr
+  - type_name: Elf64_Addr
+  - type_name: Elf64_Half
+  - type_name: Elf64_Off
+  - type_name: Elf64_Sword
+  - type_name: Elf64_Sxword
+  - type_name: Elf64_Word
+  - type_name: Elf64_Lword
+  - type_name: Elf64_Xword
+  - type_name: Elf64_Ehdr
+  - type_name: Elf64_Phdr
+  - type_name: Elf64_Nhdr
 enums: []
 objects: []
 functions: []
diff --git a/libc/include/llvm-libc-macros/elf-macros.h b/libc/include/llvm-libc-macros/elf-macros.h
index fa4442abf0f5c..fffcbb62527a7 100644
--- a/libc/include/llvm-libc-macros/elf-macros.h
+++ b/libc/include/llvm-libc-macros/elf-macros.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_MACROS_ELF_MACROS_H
 #define LLVM_LIBC_MACROS_ELF_MACROS_H
 
-#if __has_include(<linux/elf.h>)
-#include <linux/elf.h>
-#else
-#error "cannot use <sys/elf.h> without proper system headers."
-#endif
+#define EI_NIDENT 16
 
 #endif // LLVM_LIBC_MACROS_ELF_MACROS_H
diff --git a/libc/include/llvm-libc-types/Elf32_Addr.h b/libc/include/llvm-libc-types/Elf32_Addr.h
new file mode 100644
index 0000000000000..16cca621fbd47
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Addr.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Addr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_ADDR_H
+#define LLVM_LIBC_TYPES_ELF32_ADDR_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint32_t Elf32_Addr;
+
+#endif // LLVM_LIBC_TYPES_ELF32_ADDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Ehdr.h b/libc/include/llvm-libc-types/Elf32_Ehdr.h
new file mode 100644
index 0000000000000..571b234a6ff6b
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Ehdr.h
@@ -0,0 +1,35 @@
+//===-- Definition of Elf32_Ehdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_EHDR_H
+#define LLVM_LIBC_TYPES_ELF32_EHDR_H
+
+#include "../llvm-libc-macros/elf-macros.h"
+#include "Elf32_Addr.h"
+#include "Elf32_Half.h"
+#include "Elf32_Off.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  unsigned char e_ident[EI_NIDENT];
+  Elf32_Half e_type;
+  Elf32_Half e_machine;
+  Elf32_Word e_version;
+  Elf32_Addr e_entry;
+  Elf32_Off e_phoff;
+  Elf32_Off e_shoff;
+  Elf32_Word e_flags;
+  Elf32_Half e_ehsize;
+  Elf32_Half e_phentsize;
+  Elf32_Half e_phnum;
+  Elf32_Half e_shentsize;
+  Elf32_Half e_shnum;
+  Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+#endif // LLVM_LIBC_TYPES_ELF32_EHDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Half.h b/libc/include/llvm-libc-types/Elf32_Half.h
new file mode 100644
index 0000000000000..b614b416d51af
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Half.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Half type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_HALF_H
+#define LLVM_LIBC_TYPES_ELF32_HALF_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint16_t Elf32_Half;
+
+#endif // LLVM_LIBC_TYPES_ELF32_HALF_H
diff --git a/libc/include/llvm-libc-types/Elf32_Lword.h b/libc/include/llvm-libc-types/Elf32_Lword.h
new file mode 100644
index 0000000000000..5d1e634a1b9b5
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Lword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Lword type ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_LWORD_H
+#define LLVM_LIBC_TYPES_ELF32_LWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint32_t Elf32_Lword;
+
+#endif // LLVM_LIBC_TYPES_ELF32_LWORD_H
diff --git a/libc/include/llvm-libc-types/Elf32_Nhdr.h b/libc/include/llvm-libc-types/Elf32_Nhdr.h
new file mode 100644
index 0000000000000..a15c1f21cd6ca
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Nhdr.h
@@ -0,0 +1,20 @@
+//===-- Definition of Elf32_Nhdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_NHDR_H
+#define LLVM_LIBC_TYPES_ELF32_NHDR_H
+
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word n_namesz;
+  Elf32_Word n_descsz;
+  Elf32_Word n_type;
+} Elf32_Note;
+
+#endif // LLVM_LIBC_TYPES_ELF32_NHDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Off.h b/libc/include/llvm-libc-types/Elf32_Off.h
new file mode 100644
index 0000000000000..46c7118d95e77
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Off.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Off type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_OFF_H
+#define LLVM_LIBC_TYPES_ELF32_OFF_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint32_t Elf32_Off;
+
+#endif // LLVM_LIBC_TYPES_ELF32_OFF_H
diff --git a/libc/include/llvm-libc-types/Elf32_Phdr.h b/libc/include/llvm-libc-types/Elf32_Phdr.h
new file mode 100644
index 0000000000000..1fcb6d0e18108
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Phdr.h
@@ -0,0 +1,27 @@
+//===-- Definition of Elf32_Phdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_PHDR_H
+#define LLVM_LIBC_TYPES_ELF32_PHDR_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Off.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word p_type;
+  Elf32_Off p_offset;
+  Elf32_Addr p_vaddr;
+  Elf32_Addr p_paddr;
+  Elf32_Word p_filesz;
+  Elf32_Word p_memsz;
+  Elf32_Word p_flags;
+  Elf32_Word p_align;
+} Elf32_Phdr;
+
+#endif // LLVM_LIBC_TYPES_ELF32_EHDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Sword.h b/libc/include/llvm-libc-types/Elf32_Sword.h
new file mode 100644
index 0000000000000..8adbba727afde
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Sword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Sword type ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_SWORD_H
+#define LLVM_LIBC_TYPES_ELF32_SWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef int32_t Elf32_Sword;
+
+#endif // LLVM_LIBC_TYPES_ELF32_SWORD_H
diff --git a/libc/include/llvm-libc-types/Elf32_Word.h b/libc/include/llvm-libc-types/Elf32_Word.h
new file mode 100644
index 0000000000000..7444a8b41ff4b
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Word.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Word type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_WORD_H
+#define LLVM_LIBC_TYPES_ELF32_WORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint32_t Elf32_Word;
+
+#endif // LLVM_LIBC_TYPES_ELF32_WORD_H
diff --git a/libc/include/llvm-libc-types/Elf64_Addr.h b/libc/include/llvm-libc-types/Elf64_Addr.h
new file mode 100644
index 0000000000000..a186c1b316f40
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Addr.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Addr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_ADDR_H
+#define LLVM_LIBC_TYPES_ELF64_ADDR_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf64_Addr;
+
+#endif // LLVM_LIBC_TYPES_ELF64_ADDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Ehdr.h b/libc/include/llvm-libc-types/Elf64_Ehdr.h
new file mode 100644
index 0000000000000..59bea9c302f51
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Ehdr.h
@@ -0,0 +1,35 @@
+//===-- Definition of Elf64_Ehdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_EHDR_H
+#define LLVM_LIBC_TYPES_ELF64_EHDR_H
+
+#include "../llvm-libc-macros/elf-macros.h"
+#include "Elf64_Addr.h"
+#include "Elf64_Half.h"
+#include "Elf64_Off.h"
+#include "Elf64_Word.h"
+
+typedef struct {
+  unsigned char e_ident[EI_NIDENT];
+  Elf64_Half e_type;
+  Elf64_Half e_machine;
+  Elf64_Word e_version;
+  Elf64_Addr e_entry;
+  Elf64_Off e_phoff;
+  Elf64_Off e_shoff;
+  Elf64_Word e_flags;
+  Elf64_Half e_ehsize;
+  Elf64_Half e_phentsize;
+  Elf64_Half e_phnum;
+  Elf64_Half e_shentsize;
+  Elf64_Half e_shnum;
+  Elf64_Half e_shstrndx;
+} Elf64_Ehdr;
+
+#endif // LLVM_LIBC_TYPES_ELF64_EHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Half.h b/libc/include/llvm-libc-types/Elf64_Half.h
new file mode 100644
index 0000000000000..2f0bfe88992d0
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Half.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Half type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_HALF_H
+#define LLVM_LIBC_TYPES_ELF64_HALF_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint16_t Elf64_Half;
+
+#endif // LLVM_LIBC_TYPES_ELF64_HALF_H
diff --git a/libc/include/llvm-libc-types/Elf64_Lword.h b/libc/include/llvm-libc-types/Elf64_Lword.h
new file mode 100644
index 0000000000000..5435e1d8e5deb
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Lword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Lword type ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_LWORD_H
+#define LLVM_LIBC_TYPES_ELF64_LWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf64_Lword;
+
+#endif // LLVM_LIBC_TYPES_ELF64_LWORD_H
diff --git a/libc/include/llvm-libc-types/Elf64_Nhdr.h b/libc/include/llvm-libc-types/Elf64_Nhdr.h
new file mode 100644
index 0000000000000..ed0e12cc03d56
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Nhdr.h
@@ -0,0 +1,20 @@
+//===-- Definition of Elf64_Nhdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_NHDR_H
+#define LLVM_LIBC_TYPES_ELF64_NHDR_H
+
+#include "Elf64_Word.h"
+
+typedef struct {
+  Elf64_Word n_namesz;
+  Elf64_Word n_descsz;
+  Elf64_Word n_type;
+} Elf64_Note;
+
+#endif // LLVM_LIBC_TYPES_ELF64_NHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Off.h b/libc/include/llvm-libc-types/Elf64_Off.h
new file mode 100644
index 0000000000000..e33c47e658152
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Off.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Off type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_OFF_H
+#define LLVM_LIBC_TYPES_ELF64_OFF_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf64_Off;
+
+#endif // LLVM_LIBC_TYPES_ELF32_OFF_H
diff --git a/libc/include/llvm-libc-types/Elf64_Phdr.h b/libc/include/llvm-libc-types/Elf64_Phdr.h
new file mode 100644
index 0000000000000..e5c96a56491d9
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Phdr.h
@@ -0,0 +1,28 @@
+//===-- Definition of Elf64_Phdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_PHDR_H
+#define LLVM_LIBC_TYPES_ELF64_PHDR_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Off.h"
+#include "Elf64_Word.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Word p_type;
+  Elf64_Word p_flags;
+  Elf64_Off p_offset;
+  Elf64_Addr p_vaddr;
+  Elf64_Addr p_paddr;
+  Elf64_Xword p_filesz;
+  Elf64_Xword p_memsz;
+  Elf64_Xword p_align;
+} Elf64_Phdr;
+
+#endif // LLVM_LIBC_TYPES_ELF64_PHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Sword.h b/libc/include/llvm-libc-types/Elf64_Sword.h
new file mode 100644
index 0000000000000..dfadd3c7b4dbf
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Sword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Sword type ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_SWORD_H
+#define LLVM_LIBC_TYPES_ELF64_SWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef int32_t Elf64_Sword;
+
+#endif // LLVM_LIBC_TYPES_ELF64_SWORD_H
diff --git a/libc/include/llvm-libc-types/Elf64_Sxword.h b/libc/include/llvm-libc-types/Elf64_Sxword.h
new file mode 100644
index 0000000000000..6f66e0d8098ac
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Sxword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Sxword type -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_SXWORD_H
+#define LLVM_LIBC_TYPES_ELF64_SXWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf64_Sxword;
+
+#endif // LLVM_LIBC_TYPES_ELF64_SXWORD_H
diff --git a/libc/include/llvm-libc-types/Elf64_Word.h b/libc/include/llvm-libc-types/Elf64_Word.h
new file mode 100644
index 0000000000000..0f001460e0549
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Word.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Word type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_WORD_H
+#define LLVM_LIBC_TYPES_ELF64_WORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint32_t Elf64_Word;
+
+#endif // LLVM_LIBC_TYPES_ELF64_WORD_H
diff --git a/libc/include/llvm-libc-types/Elf64_Xword.h b/libc/include/llvm-libc-types/Elf64_Xword.h
new file mode 100644
index 0000000000000..70438b612dbed
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Xword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Xword type ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_XWORD_H
+#define LLVM_LIBC_TYPES_ELF64_XWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf64_Xword;
+
+#endif // LLVM_LIBC_TYPES_ELF64_XWORD_H

>From f2ec161cfe9a86f597cf22603b19148f6e7f1622 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 18 Dec 2025 02:18:00 +0000
Subject: [PATCH 2/9] Update CMake files

---
 libc/include/CMakeLists.txt                 | 20 +++++++
 libc/include/elf.yaml                       |  2 +
 libc/include/llvm-libc-types/CMakeLists.txt | 60 +++++++++++++++++++++
 3 files changed, 82 insertions(+)

diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 96c3a88f3fcc8..a76f15b95bcb8 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -477,6 +477,26 @@ add_header_macro(
   elf.h
   DEPENDS
     .llvm-libc-macros.elf_macros
+    .llvm-libc-types.Elf32_Addr
+    .llvm-libc-types.Elf32_Ehdr
+    .llvm-libc-types.Elf32_Half
+    .llvm-libc-types.Elf32_Lword
+    .llvm-libc-types.Elf32_Nhdr
+    .llvm-libc-types.Elf32_Off
+    .llvm-libc-types.Elf32_Phdr
+    .llvm-libc-types.Elf32_Sword
+    .llvm-libc-types.Elf32_Word
+    .llvm-libc-types.Elf64_Addr
+    .llvm-libc-types.Elf64_Ehdr
+    .llvm-libc-types.Elf64_Half
+    .llvm-libc-types.Elf64_Lword
+    .llvm-libc-types.Elf64_Nhdr
+    .llvm-libc-types.Elf64_Off
+    .llvm-libc-types.Elf64_Phdr
+    .llvm-libc-types.Elf64_Sword
+    .llvm-libc-types.Elf64_Sxword
+    .llvm-libc-types.Elf64_Word
+    .llvm-libc-types.Elf64_Xword
 )
 
 # TODO: Not all platforms will have a include/sys directory. Add the sys
diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index c433b9d495c9c..d1ef5d0f1e621 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -3,6 +3,8 @@ header_template: elf.h.def
 standards:
   - svid
 macros:
+  - macro_name: EI_NIDENT
+    macro_header: elf-macros.h
   - macro_name: EI_MAG0
     macro_value: 0
   - macro_name: EI_MAG1
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index fcd0e1245a4a8..44d8e733b63d1 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -187,6 +187,66 @@ add_header(uint_ulk_t HDR uint_ulk_t.h)
 add_header(uint_ulr_t HDR uint_ulr_t.h)
 add_header(uint_ur_t HDR uint_ur_t.h)
 
+# ELF
+add_header(Elf32_Addr HDR Elf32_Addr.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Half HDR Elf32_Half.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Lword HDR Elf32_Lword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Off HDR Elf32_Off.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Sword HDR Elf32_Sword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Word HDR Elf32_Word.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(
+  Elf32_Ehdr
+  HDR
+    Elf32_Ehdr.h
+  DEPENDS
+    libc.include.llvm-libc-macros.elf_macros
+    .Elf32_Addr
+    .Elf32_Half
+    .Elf32_Off
+    .Elf32_Word
+)
+add_header(Elf32_Nhdr HDR Elf32_Nhdr.h DEPENDS .Elf32_Word)
+add_header(
+  Elf32_Phdr
+  HDR
+    Elf32_Phdr.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Off
+    .Elf32_Word
+)
+
+add_header(Elf64_Addr HDR Elf64_Addr.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Half HDR Elf64_Half.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Lword HDR Elf64_Lword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Off HDR Elf64_Off.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Sword HDR Elf64_Sword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Sxword HDR Elf64_Sxword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Word HDR Elf64_Word.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf64_Xword HDR Elf64_Xword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(
+  Elf64_Ehdr
+  HDR
+    Elf64_Ehdr.h
+  DEPENDS
+    libc.include.llvm-libc-macros.elf_macros
+    .Elf64_Addr
+    .Elf64_Half
+    .Elf64_Off
+    .Elf64_Word
+)
+add_header(Elf64_Nhdr HDR Elf64_Nhdr.h DEPENDS .Elf64_Word)
+add_header(
+  Elf64_Phdr
+  HDR
+    Elf64_Phdr.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Off
+    .Elf64_Word
+    .Elf64_Xword
+)
+
 # UEFI
 add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(EFI_CONFIGURATION_TABLE HDR EFI_CONFIGURATION_TABLE.h DEPENDS .EFI_GUID)

>From 96f394f321963b3ac05d087c206fc642210ca1a3 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 18 Dec 2025 03:21:00 +0000
Subject: [PATCH 3/9] Define machine and OSABI values

---
 libc/include/elf.yaml                     | 12 ++++++++++++
 libc/include/llvm-libc-types/Elf32_Nhdr.h |  2 +-
 libc/include/llvm-libc-types/Elf64_Nhdr.h |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index d1ef5d0f1e621..4fffe3de0ed94 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -53,6 +53,8 @@ macros:
     macro_value: 2
   - macro_name: ELFOSABI_NONE
     macro_value: 0
+  - macro_name: ELFOSABI_LINUX
+    macro_value: 3
   - macro_name: ET_NONE
     macro_value: 0
   - macro_name: ET_REL
@@ -73,6 +75,16 @@ macros:
     macro_value: '0xffff'
   - macro_name: EM_NONE
     macro_value: 0
+  - macro_name: EM_386
+    macro_value: 3
+  - macro_name: EM_ARM
+    macro_value: 40
+  - macro_name: EM_X86_64
+    macro_value: 62
+  - macro_name: EM_AARCH64
+    macro_value: 183
+  - macro_name: EM_RISCV
+    macro_value: 243
   - macro_name: EV_NONE
     macro_value: 0
   - macro_name: EV_CURRENT
diff --git a/libc/include/llvm-libc-types/Elf32_Nhdr.h b/libc/include/llvm-libc-types/Elf32_Nhdr.h
index a15c1f21cd6ca..2deca0376fa15 100644
--- a/libc/include/llvm-libc-types/Elf32_Nhdr.h
+++ b/libc/include/llvm-libc-types/Elf32_Nhdr.h
@@ -15,6 +15,6 @@ typedef struct {
   Elf32_Word n_namesz;
   Elf32_Word n_descsz;
   Elf32_Word n_type;
-} Elf32_Note;
+} Elf32_Nhdr;
 
 #endif // LLVM_LIBC_TYPES_ELF32_NHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Nhdr.h b/libc/include/llvm-libc-types/Elf64_Nhdr.h
index ed0e12cc03d56..7e42f0fc8988f 100644
--- a/libc/include/llvm-libc-types/Elf64_Nhdr.h
+++ b/libc/include/llvm-libc-types/Elf64_Nhdr.h
@@ -15,6 +15,6 @@ typedef struct {
   Elf64_Word n_namesz;
   Elf64_Word n_descsz;
   Elf64_Word n_type;
-} Elf64_Note;
+} Elf64_Nhdr;
 
 #endif // LLVM_LIBC_TYPES_ELF64_NHDR_H

>From d2efabe59f9b1f448cf7e08c2518f676c0a23b28 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Thu, 18 Dec 2025 07:30:06 +0000
Subject: [PATCH 4/9] More types

---
 libc/include/elf.yaml                       |  12 +++
 libc/include/llvm-libc-types/CMakeLists.txt | 106 ++++++++++++++++++++
 libc/include/llvm-libc-types/Elf32_Chdr.h   |  20 ++++
 libc/include/llvm-libc-types/Elf32_Dyn.h    |  24 +++++
 libc/include/llvm-libc-types/Elf32_Rel.h    |  20 ++++
 libc/include/llvm-libc-types/Elf32_Rela.h   |  22 ++++
 libc/include/llvm-libc-types/Elf32_Shdr.h   |  29 ++++++
 libc/include/llvm-libc-types/Elf32_Sym.h    |  25 +++++
 libc/include/llvm-libc-types/Elf64_Chdr.h   |  22 ++++
 libc/include/llvm-libc-types/Elf64_Dyn.h    |  25 +++++
 libc/include/llvm-libc-types/Elf64_Rel.h    |  20 ++++
 libc/include/llvm-libc-types/Elf64_Rela.h   |  22 ++++
 libc/include/llvm-libc-types/Elf64_Shdr.h   |  30 ++++++
 libc/include/llvm-libc-types/Elf64_Sym.h    |  26 +++++
 14 files changed, 403 insertions(+)
 create mode 100644 libc/include/llvm-libc-types/Elf32_Chdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Dyn.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Rel.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Rela.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Shdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Sym.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Chdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Dyn.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Rel.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Rela.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Shdr.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Sym.h

diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index 4fffe3de0ed94..1ad98b6794019 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -160,9 +160,15 @@ types:
   - type_name: Elf32_Sword
   - type_name: Elf32_Word
   - type_name: Elf32_Lword
+  - type_name: Elf32_Chdr
+  - type_name: Elf32_Dyn
   - type_name: Elf32_Ehdr
   - type_name: Elf32_Phdr
   - type_name: Elf32_Nhdr
+  - type_name: Elf32_Rel
+  - type_name: Elf32_Rela
+  - type_name: Elf32_Shdr
+  - type_name: Elf32_Sym
   - type_name: Elf64_Addr
   - type_name: Elf64_Half
   - type_name: Elf64_Off
@@ -171,9 +177,15 @@ types:
   - type_name: Elf64_Word
   - type_name: Elf64_Lword
   - type_name: Elf64_Xword
+  - type_name: Elf64_Chdr
+  - type_name: Elf64_Dyn
   - type_name: Elf64_Ehdr
   - type_name: Elf64_Phdr
   - type_name: Elf64_Nhdr
+  - type_name: Elf64_Rel
+  - type_name: Elf64_Rela
+  - type_name: Elf64_Shdr
+  - type_name: Elf64_Sym
 enums: []
 objects: []
 functions: []
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 44d8e733b63d1..cb2c2b243c964 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -194,6 +194,22 @@ add_header(Elf32_Lword HDR Elf32_Lword.h DEPENDS libc.include.llvm-libc-macros.s
 add_header(Elf32_Off HDR Elf32_Off.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf32_Sword HDR Elf32_Sword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf32_Word HDR Elf32_Word.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(
+  Elf32_Chdr
+  HDR
+    Elf32_Chdr.h
+  DEPENDS
+    .Elf32_Word
+)
+add_header(
+  Elf32_Dyn
+  HDR
+    Elf32_Dyn.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Sword
+    .Elf32_Word
+)
 add_header(
   Elf32_Ehdr
   HDR
@@ -215,6 +231,41 @@ add_header(
     .Elf32_Off
     .Elf32_Word
 )
+add_header(
+  Elf32_Rel
+  HDR
+    Elf32_Rel.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Word
+)
+add_header(
+  Elf32_Rela
+  HDR
+    Elf32_Rela.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Sword
+    .Elf32_Word
+)
+add_header(
+  Elf32_Shdr
+  HDR
+    Elf32_Shdr.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Off
+    .Elf32_Word
+)
+add_header(
+  Elf32_Sym
+  HDR
+    Elf32_Sym.h
+  DEPENDS
+    .Elf32_Addr
+    .Elf32_Half
+    .Elf32_Word
+)
 
 add_header(Elf64_Addr HDR Elf64_Addr.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf64_Half HDR Elf64_Half.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
@@ -224,6 +275,24 @@ add_header(Elf64_Sword HDR Elf64_Sword.h DEPENDS libc.include.llvm-libc-macros.s
 add_header(Elf64_Sxword HDR Elf64_Sxword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf64_Word HDR Elf64_Word.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf64_Xword HDR Elf64_Xword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(
+  Elf64_Chdr
+  HDR
+    Elf64_Chdr.h
+  DEPENDS
+    .Elf64_Word
+    .Elf64_Xword
+)
+add_header(
+  Elf64_Dyn
+  HDR
+    Elf64_Dyn.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Off
+    .Elf64_Sxword
+    .Elf64_Xword
+)
 add_header(
   Elf64_Ehdr
   HDR
@@ -246,6 +315,43 @@ add_header(
     .Elf64_Word
     .Elf64_Xword
 )
+add_header(
+  Elf64_Rel
+  HDR
+    Elf64_Rel.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Xword
+)
+add_header(
+  Elf64_Rela
+  HDR
+    Elf64_Rela.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Sxword
+    .Elf64_Xword
+)
+add_header(
+  Elf64_Shdr
+  HDR
+    Elf64_Shdr.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Off
+    .Elf64_Word
+    .Elf64_Xword
+)
+add_header(
+  Elf64_Sym
+  HDR
+    Elf64_Sym.h
+  DEPENDS
+    .Elf64_Addr
+    .Elf64_Half
+    .Elf64_Word
+    .Elf64_Xword
+)
 
 # UEFI
 add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
diff --git a/libc/include/llvm-libc-types/Elf32_Chdr.h b/libc/include/llvm-libc-types/Elf32_Chdr.h
new file mode 100644
index 0000000000000..dad95b9a6d797
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Chdr.h
@@ -0,0 +1,20 @@
+//===-- Definition of Elf32_Chdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_CHDR_H
+#define LLVM_LIBC_TYPES_ELF32_CHDR_H
+
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word ch_type;
+  Elf32_Word ch_size;
+  Elf32_Word ch_addralign;
+} Elf32_Chdr;
+
+#endif // LLVM_LIBC_TYPES_ELF32_CHDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Dyn.h b/libc/include/llvm-libc-types/Elf32_Dyn.h
new file mode 100644
index 0000000000000..f3539be1d77eb
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Dyn.h
@@ -0,0 +1,24 @@
+//===-- Definition of Elf32_Dyn type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_DYN_H
+#define LLVM_LIBC_TYPES_ELF32_DYN_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Sword.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Sword d_tag;
+  union {
+    Elf32_Word d_val;
+    Elf32_Addr d_ptr;
+  } d_un;
+} Elf32_Dyn;
+
+#endif // NLLVM_LIBC_TYPES_ELF32_DYN_H
diff --git a/libc/include/llvm-libc-types/Elf32_Rel.h b/libc/include/llvm-libc-types/Elf32_Rel.h
new file mode 100644
index 0000000000000..a712add4bd218
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Rel.h
@@ -0,0 +1,20 @@
+//===-- Definition of Elf32_Rel type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_REL_H
+#define LLVM_LIBC_TYPES_ELF32_REL_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Addr r_offset;
+  Elf32_Word r_info;
+} Elf32_Rel;
+
+#endif // LLVM_LIBC_TYPES_ELF32_REL_H
diff --git a/libc/include/llvm-libc-types/Elf32_Rela.h b/libc/include/llvm-libc-types/Elf32_Rela.h
new file mode 100644
index 0000000000000..a1eabcd703d85
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Rela.h
@@ -0,0 +1,22 @@
+//===-- Definition of Elf32_Rela type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_RELA_H
+#define LLVM_LIBC_TYPES_ELF32_RELA_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Sword.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Addr r_offset;
+  Elf32_Word r_info;
+  Elf32_Sword r_addend;
+} Elf32_Rela;
+
+#endif // LLVM_LIBC_TYPES_ELF32_RELA_H
diff --git a/libc/include/llvm-libc-types/Elf32_Shdr.h b/libc/include/llvm-libc-types/Elf32_Shdr.h
new file mode 100644
index 0000000000000..179a2c7c3f4e7
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Shdr.h
@@ -0,0 +1,29 @@
+//===-- Definition of Elf32_Shdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_SHDR_H
+#define LLVM_LIBC_TYPES_ELF32_SHDR_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Off.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word sh_name;
+  Elf32_Word sh_type;
+  Elf32_Word sh_flags;
+  Elf32_Addr sh_addr;
+  Elf32_Off sh_offset;
+  Elf32_Word sh_size;
+  Elf32_Word sh_link;
+  Elf32_Word sh_info;
+  Elf32_Word sh_addralign;
+  Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+#endif // LLVM_LIBC_TYPES_ELF32_SHDR_H
diff --git a/libc/include/llvm-libc-types/Elf32_Sym.h b/libc/include/llvm-libc-types/Elf32_Sym.h
new file mode 100644
index 0000000000000..7363abc1792c6
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Sym.h
@@ -0,0 +1,25 @@
+//===-- Definition of Elf32_Sym type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_SYM_H
+#define LLVM_LIBC_TYPES_ELF32_SYM_H
+
+#include "Elf32_Addr.h"
+#include "Elf32_Half.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word st_name;
+  Elf32_Addr st_value;
+  Elf32_Word st_size;
+  unsigned char st_info;
+  unsigned char st_other;
+  Elf32_Half st_shndx;
+} Elf32_Sym;
+
+#endif // LLVM_LIBC_TYPES_ELF32_SYM_H
diff --git a/libc/include/llvm-libc-types/Elf64_Chdr.h b/libc/include/llvm-libc-types/Elf64_Chdr.h
new file mode 100644
index 0000000000000..7110f5b45d16e
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Chdr.h
@@ -0,0 +1,22 @@
+//===-- Definition of Elf64_Chdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_CHDR_H
+#define LLVM_LIBC_TYPES_ELF64_CHDR_H
+
+#include "Elf64_Word.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Word ch_type;
+  Elf64_Word ch_reserved;
+  Elf64_Xword ch_size;
+  Elf64_Xword ch_addralign;
+} Elf64_Chdr;
+
+#endif // LLVM_LIBC_TYPES_ELF64_CHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Dyn.h b/libc/include/llvm-libc-types/Elf64_Dyn.h
new file mode 100644
index 0000000000000..7efc793e2fa03
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Dyn.h
@@ -0,0 +1,25 @@
+//===-- Definition of Elf64_Dyn type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_DYN_H
+#define LLVM_LIBC_TYPES_ELF64_DYN_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Off.h"
+#include "Elf64_Sxword.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Sxword d_tag;
+  union {
+    Elf64_Xword d_val;
+    Elf64_Addr d_ptr;
+  } d_un;
+} Elf64_Dyn;
+
+#endif // LLVM_LIBC_TYPES_ELF64_DYN_H
diff --git a/libc/include/llvm-libc-types/Elf64_Rel.h b/libc/include/llvm-libc-types/Elf64_Rel.h
new file mode 100644
index 0000000000000..48e670c8d14f0
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Rel.h
@@ -0,0 +1,20 @@
+//===-- Definition of Elf64_Rel type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_REL_H
+#define LLVM_LIBC_TYPES_ELF64_REL_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Addr r_offset;
+  Elf64_Xword r_info;
+} Elf64_Rel;
+
+#endif // LLVM_LIBC_TYPES_ELF64_REL_H
diff --git a/libc/include/llvm-libc-types/Elf64_Rela.h b/libc/include/llvm-libc-types/Elf64_Rela.h
new file mode 100644
index 0000000000000..945ecd228829f
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Rela.h
@@ -0,0 +1,22 @@
+//===-- Definition of Elf64_Rela type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_RELA_H
+#define LLVM_LIBC_TYPES_ELF64_RELA_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Sxword.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Addr r_offset;
+  Elf64_Xword r_info;
+  Elf64_Sxword r_addend;
+} Elf64_Rela;
+
+#endif // LLVM_LIBC_TYPES_ELF64_RELA_H
diff --git a/libc/include/llvm-libc-types/Elf64_Shdr.h b/libc/include/llvm-libc-types/Elf64_Shdr.h
new file mode 100644
index 0000000000000..7ffd1e71a1f96
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Shdr.h
@@ -0,0 +1,30 @@
+//===-- Definition of Elf64_Shdr type -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_SHDR_H
+#define LLVM_LIBC_TYPES_ELF64_SHDR_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Off.h"
+#include "Elf64_Word.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Word sh_name;
+  Elf64_Word sh_type;
+  Elf64_Xword sh_flags;
+  Elf64_Addr sh_addr;
+  Elf64_Off sh_offset;
+  Elf64_Xword sh_size;
+  Elf64_Word sh_link;
+  Elf64_Word sh_info;
+  Elf64_Xword sh_addralign;
+  Elf64_Xword sh_entsize;
+} Elf64_Shdr;
+
+#endif // LLVM_LIBC_TYPES_ELF64_SHDR_H
diff --git a/libc/include/llvm-libc-types/Elf64_Sym.h b/libc/include/llvm-libc-types/Elf64_Sym.h
new file mode 100644
index 0000000000000..367c72897fc60
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Sym.h
@@ -0,0 +1,26 @@
+//===-- Definition of Elf64_Sym type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_SYM_H
+#define LLVM_LIBC_TYPES_ELF64_SYM_H
+
+#include "Elf64_Addr.h"
+#include "Elf64_Half.h"
+#include "Elf64_Word.h"
+#include "Elf64_Xword.h"
+
+typedef struct {
+  Elf64_Word st_name;
+  unsigned char st_info;
+  unsigned char st_other;
+  Elf64_Half st_shndx;
+  Elf64_Addr st_value;
+  Elf64_Xword st_size;
+} Elf64_Sym;
+
+#endif // LLVM_LIBC_TYPES_ELF64_SYM_H

>From 7cf404033a1a9252bbd09cf0d565b467951802d1 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Dec 2025 03:55:22 +0000
Subject: [PATCH 5/9] More types and proxy headers

---
 clang/cmake/caches/Fuchsia-stage2.cmake       |   2 +-
 libc/hdr/elf_macros.h                         |  22 ++
 libc/hdr/types/CMakeLists.txt                 | 336 ++++++++++++++++++
 libc/hdr/types/Elf32_Addr.h                   |  23 ++
 libc/hdr/types/Elf32_Chdr.h                   |  23 ++
 libc/hdr/types/Elf32_Dyn.h                    |  23 ++
 libc/hdr/types/Elf32_Ehdr.h                   |  23 ++
 libc/hdr/types/Elf32_Half.h                   |  23 ++
 libc/hdr/types/Elf32_Lword.h                  |  23 ++
 libc/hdr/types/Elf32_Nhdr.h                   |  23 ++
 libc/hdr/types/Elf32_Off.h                    |  23 ++
 libc/hdr/types/Elf32_Phdr.h                   |  23 ++
 libc/hdr/types/Elf32_Rel.h                    |  23 ++
 libc/hdr/types/Elf32_Rela.h                   |  23 ++
 libc/hdr/types/Elf32_Shdr.h                   |  23 ++
 libc/hdr/types/Elf32_Sword.h                  |  23 ++
 libc/hdr/types/Elf32_Sym.h                    |  23 ++
 libc/hdr/types/Elf32_Verdaux.h                |  23 ++
 libc/hdr/types/Elf32_Verdef.h                 |  23 ++
 libc/hdr/types/Elf32_Vernaux.h                |  23 ++
 libc/hdr/types/Elf32_Verneed.h                |  23 ++
 libc/hdr/types/Elf32_Versym.h                 |  23 ++
 libc/hdr/types/Elf32_Word.h                   |  23 ++
 libc/hdr/types/Elf64_Addr.h                   |  23 ++
 libc/hdr/types/Elf64_Chdr.h                   |  23 ++
 libc/hdr/types/Elf64_Dyn.h                    |  23 ++
 libc/hdr/types/Elf64_Ehdr.h                   |  23 ++
 libc/hdr/types/Elf64_Half.h                   |  23 ++
 libc/hdr/types/Elf64_Lword.h                  |  23 ++
 libc/hdr/types/Elf64_Nhdr.h                   |  23 ++
 libc/hdr/types/Elf64_Off.h                    |  23 ++
 libc/hdr/types/Elf64_Phdr.h                   |  23 ++
 libc/hdr/types/Elf64_Rel.h                    |  23 ++
 libc/hdr/types/Elf64_Rela.h                   |  23 ++
 libc/hdr/types/Elf64_Shdr.h                   |  23 ++
 libc/hdr/types/Elf64_Sword.h                  |  23 ++
 libc/hdr/types/Elf64_Sxword.h                 |  23 ++
 libc/hdr/types/Elf64_Sym.h                    |  23 ++
 libc/hdr/types/Elf64_Verdaux.h                |  23 ++
 libc/hdr/types/Elf64_Verdef.h                 |  23 ++
 libc/hdr/types/Elf64_Vernaux.h                |  23 ++
 libc/hdr/types/Elf64_Verneed.h                |  23 ++
 libc/hdr/types/Elf64_Versym.h                 |  23 ++
 libc/hdr/types/Elf64_Word.h                   |  23 ++
 libc/hdr/types/Elf64_Xword.h                  |  23 ++
 libc/include/CMakeLists.txt                   |  10 +
 libc/include/elf.yaml                         | 302 +++++++++++++++-
 libc/include/link.h.def                       |  19 +
 libc/include/link.yaml                        |   1 +
 libc/include/llvm-libc-macros/elf-macros.h    |  23 +-
 libc/include/llvm-libc-macros/link-macros.h   |  33 +-
 libc/include/llvm-libc-types/CMakeLists.txt   |  78 +++-
 libc/include/llvm-libc-types/Elf32_Dyn.h      |   2 +-
 libc/include/llvm-libc-types/Elf32_Ehdr.h     |   3 +-
 libc/include/llvm-libc-types/Elf32_Verdaux.h  |  19 +
 libc/include/llvm-libc-types/Elf32_Verdef.h   |  25 ++
 libc/include/llvm-libc-types/Elf32_Vernaux.h  |  23 ++
 libc/include/llvm-libc-types/Elf32_Verneed.h  |  23 ++
 libc/include/llvm-libc-types/Elf32_Versym.h   |  16 +
 libc/include/llvm-libc-types/Elf64_Ehdr.h     |   3 +-
 libc/include/llvm-libc-types/Elf64_Verdaux.h  |  19 +
 libc/include/llvm-libc-types/Elf64_Verdef.h   |  25 ++
 libc/include/llvm-libc-types/Elf64_Vernaux.h  |  23 ++
 libc/include/llvm-libc-types/Elf64_Verneed.h  |  23 ++
 libc/include/llvm-libc-types/Elf64_Versym.h   |  16 +
 .../src/__support/OSUtil/linux/CMakeLists.txt |  25 +-
 libc/src/__support/OSUtil/linux/vdso.cpp      |  64 ++--
 libc/startup/linux/CMakeLists.txt             |  10 +-
 libc/startup/linux/do_start.cpp               |  10 +-
 69 files changed, 2056 insertions(+), 65 deletions(-)
 create mode 100644 libc/hdr/elf_macros.h
 create mode 100644 libc/hdr/types/Elf32_Addr.h
 create mode 100644 libc/hdr/types/Elf32_Chdr.h
 create mode 100644 libc/hdr/types/Elf32_Dyn.h
 create mode 100644 libc/hdr/types/Elf32_Ehdr.h
 create mode 100644 libc/hdr/types/Elf32_Half.h
 create mode 100644 libc/hdr/types/Elf32_Lword.h
 create mode 100644 libc/hdr/types/Elf32_Nhdr.h
 create mode 100644 libc/hdr/types/Elf32_Off.h
 create mode 100644 libc/hdr/types/Elf32_Phdr.h
 create mode 100644 libc/hdr/types/Elf32_Rel.h
 create mode 100644 libc/hdr/types/Elf32_Rela.h
 create mode 100644 libc/hdr/types/Elf32_Shdr.h
 create mode 100644 libc/hdr/types/Elf32_Sword.h
 create mode 100644 libc/hdr/types/Elf32_Sym.h
 create mode 100644 libc/hdr/types/Elf32_Verdaux.h
 create mode 100644 libc/hdr/types/Elf32_Verdef.h
 create mode 100644 libc/hdr/types/Elf32_Vernaux.h
 create mode 100644 libc/hdr/types/Elf32_Verneed.h
 create mode 100644 libc/hdr/types/Elf32_Versym.h
 create mode 100644 libc/hdr/types/Elf32_Word.h
 create mode 100644 libc/hdr/types/Elf64_Addr.h
 create mode 100644 libc/hdr/types/Elf64_Chdr.h
 create mode 100644 libc/hdr/types/Elf64_Dyn.h
 create mode 100644 libc/hdr/types/Elf64_Ehdr.h
 create mode 100644 libc/hdr/types/Elf64_Half.h
 create mode 100644 libc/hdr/types/Elf64_Lword.h
 create mode 100644 libc/hdr/types/Elf64_Nhdr.h
 create mode 100644 libc/hdr/types/Elf64_Off.h
 create mode 100644 libc/hdr/types/Elf64_Phdr.h
 create mode 100644 libc/hdr/types/Elf64_Rel.h
 create mode 100644 libc/hdr/types/Elf64_Rela.h
 create mode 100644 libc/hdr/types/Elf64_Shdr.h
 create mode 100644 libc/hdr/types/Elf64_Sword.h
 create mode 100644 libc/hdr/types/Elf64_Sxword.h
 create mode 100644 libc/hdr/types/Elf64_Sym.h
 create mode 100644 libc/hdr/types/Elf64_Verdaux.h
 create mode 100644 libc/hdr/types/Elf64_Verdef.h
 create mode 100644 libc/hdr/types/Elf64_Vernaux.h
 create mode 100644 libc/hdr/types/Elf64_Verneed.h
 create mode 100644 libc/hdr/types/Elf64_Versym.h
 create mode 100644 libc/hdr/types/Elf64_Word.h
 create mode 100644 libc/hdr/types/Elf64_Xword.h
 create mode 100644 libc/include/link.h.def
 create mode 100644 libc/include/llvm-libc-types/Elf32_Verdaux.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Verdef.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Vernaux.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Verneed.h
 create mode 100644 libc/include/llvm-libc-types/Elf32_Versym.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Verdaux.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Verdef.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Vernaux.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Verneed.h
 create mode 100644 libc/include/llvm-libc-types/Elf64_Versym.h

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index be41a6db7dff3..c2ab68dfc07d7 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -462,7 +462,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-libtool-darwin
   llvm-lipo
   llvm-ml
-  llvm-mt
+  #llvm-mt
   llvm-nm
   llvm-objcopy
   llvm-objdump
diff --git a/libc/hdr/elf_macros.h b/libc/hdr/elf_macros.h
new file mode 100644
index 0000000000000..804da4d88c661
--- /dev/null
+++ b/libc/hdr/elf_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from elf.h -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_ELF_MACROS_H
+#define LLVM_LIBC_HDR_ELF_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/elf-macros.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_ELF_MACROS_H
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 433c47b174766..362feefa67783 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -487,3 +487,339 @@ add_proxy_header_library(
   FULL_BUILD_DEPENDS
     libc.include.llvm-libc-types.gid_t
 )
+
+add_proxy_header_library(
+  Elf32_Addr
+  HDRS
+    Elf32_Addr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Addr
+)
+
+add_proxy_header_library(
+  Elf32_Chdr
+  HDRS
+    Elf32_Chdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Chdr
+)
+
+add_proxy_header_library(
+  Elf32_Dyn
+  HDRS
+    Elf32_Dyn.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Dyn
+)
+
+add_proxy_header_library(
+  Elf32_Ehdr
+  HDRS
+    Elf32_Ehdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Ehdr
+)
+
+add_proxy_header_library(
+  Elf32_Half
+  HDRS
+    Elf32_Half.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Half
+)
+
+add_proxy_header_library(
+  Elf32_Lword
+  HDRS
+    Elf32_Lword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Lword
+)
+
+add_proxy_header_library(
+  Elf32_Nhdr
+  HDRS
+    Elf32_Nhdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Nhdr
+)
+
+add_proxy_header_library(
+  Elf32_Off
+  HDRS
+    Elf32_Off.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Off
+)
+
+add_proxy_header_library(
+  Elf32_Phdr
+  HDRS
+    Elf32_Phdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Phdr
+)
+
+add_proxy_header_library(
+  Elf32_Rela
+  HDRS
+    Elf32_Rela.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Rela
+)
+
+add_proxy_header_library(
+  Elf32_Rel
+  HDRS
+    Elf32_Rel.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Rel
+)
+
+add_proxy_header_library(
+  Elf32_Shdr
+  HDRS
+    Elf32_Shdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Shdr
+)
+
+add_proxy_header_library(
+  Elf32_Sword
+  HDRS
+    Elf32_Sword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Sword
+)
+
+add_proxy_header_library(
+  Elf32_Sym
+  HDRS
+    Elf32_Sym.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Sym
+)
+
+add_proxy_header_library(
+  Elf32_Verdaux
+  HDRS
+    Elf32_Verdaux.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Verdaux
+)
+
+add_proxy_header_library(
+  Elf32_Verdef
+  HDRS
+    Elf32_Verdef.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Verdef
+)
+
+add_proxy_header_library(
+  Elf32_Vernaux
+  HDRS
+    Elf32_Vernaux.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Vernaux
+)
+
+add_proxy_header_library(
+  Elf32_Verneed
+  HDRS
+    Elf32_Verneed.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Verneed
+)
+
+add_proxy_header_library(
+  Elf32_Versym
+  HDRS
+    Elf32_Versym.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Versym
+)
+
+add_proxy_header_library(
+  Elf32_Word
+  HDRS
+    Elf32_Word.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Word
+)
+
+add_proxy_header_library(
+  Elf64_Addr
+  HDRS
+    Elf64_Addr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Addr
+)
+
+add_proxy_header_library(
+  Elf64_Chdr
+  HDRS
+    Elf64_Chdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Chdr
+)
+
+add_proxy_header_library(
+  Elf64_Dyn
+  HDRS
+    Elf64_Dyn.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Dyn
+)
+
+add_proxy_header_library(
+  Elf64_Ehdr
+  HDRS
+    Elf64_Ehdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Ehdr
+)
+
+add_proxy_header_library(
+  Elf64_Half
+  HDRS
+    Elf64_Half.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Half
+)
+
+add_proxy_header_library(
+  Elf64_Lword
+  HDRS
+    Elf64_Lword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Lword
+)
+
+add_proxy_header_library(
+  Elf64_Nhdr
+  HDRS
+    Elf64_Nhdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Nhdr
+)
+
+add_proxy_header_library(
+  Elf64_Off
+  HDRS
+    Elf64_Off.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Off
+)
+
+add_proxy_header_library(
+  Elf64_Phdr
+  HDRS
+    Elf64_Phdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Phdr
+)
+
+add_proxy_header_library(
+  Elf64_Rela
+  HDRS
+    Elf64_Rela.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Rela
+)
+
+add_proxy_header_library(
+  Elf64_Rel
+  HDRS
+    Elf64_Rel.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Rel
+)
+
+add_proxy_header_library(
+  Elf64_Shdr
+  HDRS
+    Elf64_Shdr.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Shdr
+)
+
+add_proxy_header_library(
+  Elf64_Sword
+  HDRS
+    Elf64_Sword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Sword
+)
+
+add_proxy_header_library(
+  Elf64_Sxword
+  HDRS
+    Elf64_Sxword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Sxword
+)
+
+add_proxy_header_library(
+  Elf64_Sym
+  HDRS
+    Elf64_Sym.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Sym
+)
+
+add_proxy_header_library(
+  Elf64_Word
+  HDRS
+    Elf64_Word.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Word
+)
+
+add_proxy_header_library(
+  Elf64_Xword
+  HDRS
+    Elf64_Xword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Xword
+)
+
+add_proxy_header_library(
+  Elf64_Verdaux
+  HDRS
+    Elf64_Verdaux.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Verdaux
+)
+
+add_proxy_header_library(
+  Elf64_Verdef
+  HDRS
+    Elf64_Verdef.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Verdef
+)
+
+add_proxy_header_library(
+  Elf64_Vernaux
+  HDRS
+    Elf64_Vernaux.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Vernaux
+)
+
+add_proxy_header_library(
+  Elf64_Verneed
+  HDRS
+    Elf64_Verneed.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Verneed
+)
+
+add_proxy_header_library(
+  Elf64_Versym
+  HDRS
+    Elf64_Versym.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf64_Versym
+)
diff --git a/libc/hdr/types/Elf32_Addr.h b/libc/hdr/types/Elf32_Addr.h
new file mode 100644
index 0000000000000..d9044528de781
--- /dev/null
+++ b/libc/hdr/types/Elf32_Addr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Addr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_ADDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_ADDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Addr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_ADDR_H
diff --git a/libc/hdr/types/Elf32_Chdr.h b/libc/hdr/types/Elf32_Chdr.h
new file mode 100644
index 0000000000000..005bb9b55e3c6
--- /dev/null
+++ b/libc/hdr/types/Elf32_Chdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Chdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_CHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_CHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Chdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_CHDR_H
diff --git a/libc/hdr/types/Elf32_Dyn.h b/libc/hdr/types/Elf32_Dyn.h
new file mode 100644
index 0000000000000..f2a3e8fabb8c6
--- /dev/null
+++ b/libc/hdr/types/Elf32_Dyn.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Dyn -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_DYN_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_DYN_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Dyn.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_DYN_H
diff --git a/libc/hdr/types/Elf32_Ehdr.h b/libc/hdr/types/Elf32_Ehdr.h
new file mode 100644
index 0000000000000..edde446c4c102
--- /dev/null
+++ b/libc/hdr/types/Elf32_Ehdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Ehdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_EHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_EHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Ehdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_EHDR_H
diff --git a/libc/hdr/types/Elf32_Half.h b/libc/hdr/types/Elf32_Half.h
new file mode 100644
index 0000000000000..9b8630c58e80b
--- /dev/null
+++ b/libc/hdr/types/Elf32_Half.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Half ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_HALF_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_HALF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Half.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_HALF_H
diff --git a/libc/hdr/types/Elf32_Lword.h b/libc/hdr/types/Elf32_Lword.h
new file mode 100644
index 0000000000000..8155b186ac900
--- /dev/null
+++ b/libc/hdr/types/Elf32_Lword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Lword ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_LWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_LWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Lword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_LWORD_H
diff --git a/libc/hdr/types/Elf32_Nhdr.h b/libc/hdr/types/Elf32_Nhdr.h
new file mode 100644
index 0000000000000..0101940178e52
--- /dev/null
+++ b/libc/hdr/types/Elf32_Nhdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Nhdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_NHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_NHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Nhdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_NHDR_H
diff --git a/libc/hdr/types/Elf32_Off.h b/libc/hdr/types/Elf32_Off.h
new file mode 100644
index 0000000000000..780bd3d2d747c
--- /dev/null
+++ b/libc/hdr/types/Elf32_Off.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Off -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_OFF_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_OFF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Off.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_OFF_H
diff --git a/libc/hdr/types/Elf32_Phdr.h b/libc/hdr/types/Elf32_Phdr.h
new file mode 100644
index 0000000000000..ba7f013dde1ad
--- /dev/null
+++ b/libc/hdr/types/Elf32_Phdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Phdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_PHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_PHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Phdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_PHDR_H
diff --git a/libc/hdr/types/Elf32_Rel.h b/libc/hdr/types/Elf32_Rel.h
new file mode 100644
index 0000000000000..0fa729633b9e4
--- /dev/null
+++ b/libc/hdr/types/Elf32_Rel.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Rel -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_REL_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_REL_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Rel.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_REL_H
diff --git a/libc/hdr/types/Elf32_Rela.h b/libc/hdr/types/Elf32_Rela.h
new file mode 100644
index 0000000000000..476451f7c5c06
--- /dev/null
+++ b/libc/hdr/types/Elf32_Rela.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Rela ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_RELA_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_RELA_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Rela.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_RELA_H
diff --git a/libc/hdr/types/Elf32_Shdr.h b/libc/hdr/types/Elf32_Shdr.h
new file mode 100644
index 0000000000000..5dec8e02b5fc4
--- /dev/null
+++ b/libc/hdr/types/Elf32_Shdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Shdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_SHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_SHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Shdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_SHDR_H
diff --git a/libc/hdr/types/Elf32_Sword.h b/libc/hdr/types/Elf32_Sword.h
new file mode 100644
index 0000000000000..44dd92499dff6
--- /dev/null
+++ b/libc/hdr/types/Elf32_Sword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Sword ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_SWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_SWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Sword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_SWORD_H
diff --git a/libc/hdr/types/Elf32_Sym.h b/libc/hdr/types/Elf32_Sym.h
new file mode 100644
index 0000000000000..930fa2ca076fa
--- /dev/null
+++ b/libc/hdr/types/Elf32_Sym.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Sym -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_SYM_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_SYM_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Sym.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_SYM_H
diff --git a/libc/hdr/types/Elf32_Verdaux.h b/libc/hdr/types/Elf32_Verdaux.h
new file mode 100644
index 0000000000000..4e2bbd48de81e
--- /dev/null
+++ b/libc/hdr/types/Elf32_Verdaux.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Verdaux -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_VERDAUX_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_VERDAUX_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Verdaux.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_VERDAUX_H
diff --git a/libc/hdr/types/Elf32_Verdef.h b/libc/hdr/types/Elf32_Verdef.h
new file mode 100644
index 0000000000000..f5f9277cddaef
--- /dev/null
+++ b/libc/hdr/types/Elf32_Verdef.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Verdef --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_VERDEF_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_VERDEF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Verdef.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_VERDEF_H
diff --git a/libc/hdr/types/Elf32_Vernaux.h b/libc/hdr/types/Elf32_Vernaux.h
new file mode 100644
index 0000000000000..ad876b2513914
--- /dev/null
+++ b/libc/hdr/types/Elf32_Vernaux.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Vernaux -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_VERNAUX_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_VERNAUX_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Vernaux.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_VERNAUX_H
diff --git a/libc/hdr/types/Elf32_Verneed.h b/libc/hdr/types/Elf32_Verneed.h
new file mode 100644
index 0000000000000..db5beae00e77f
--- /dev/null
+++ b/libc/hdr/types/Elf32_Verneed.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Verneed -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_VERNEED_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_VERNEED_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Verneed.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_VERNEED_H
diff --git a/libc/hdr/types/Elf32_Versym.h b/libc/hdr/types/Elf32_Versym.h
new file mode 100644
index 0000000000000..c71271029ee11
--- /dev/null
+++ b/libc/hdr/types/Elf32_Versym.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Versym --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_VERSYM_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_VERSYM_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Versym.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_VERSYM_H
diff --git a/libc/hdr/types/Elf32_Word.h b/libc/hdr/types/Elf32_Word.h
new file mode 100644
index 0000000000000..579b0c7c48350
--- /dev/null
+++ b/libc/hdr/types/Elf32_Word.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf32_Word ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF32_WORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_WORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Word.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_WORD_H
diff --git a/libc/hdr/types/Elf64_Addr.h b/libc/hdr/types/Elf64_Addr.h
new file mode 100644
index 0000000000000..45d1700af4136
--- /dev/null
+++ b/libc/hdr/types/Elf64_Addr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Addr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_ADDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_ADDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Addr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_ADDR_H
diff --git a/libc/hdr/types/Elf64_Chdr.h b/libc/hdr/types/Elf64_Chdr.h
new file mode 100644
index 0000000000000..f96febb9cd60e
--- /dev/null
+++ b/libc/hdr/types/Elf64_Chdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Chdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_CHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_CHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Chdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_CHDR_H
diff --git a/libc/hdr/types/Elf64_Dyn.h b/libc/hdr/types/Elf64_Dyn.h
new file mode 100644
index 0000000000000..049612b4edea8
--- /dev/null
+++ b/libc/hdr/types/Elf64_Dyn.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Dyn -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_DYN_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_DYN_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Dyn.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_DYN_H
diff --git a/libc/hdr/types/Elf64_Ehdr.h b/libc/hdr/types/Elf64_Ehdr.h
new file mode 100644
index 0000000000000..0de4c0d51719f
--- /dev/null
+++ b/libc/hdr/types/Elf64_Ehdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Ehdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_EHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_EHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Ehdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_EHDR_H
diff --git a/libc/hdr/types/Elf64_Half.h b/libc/hdr/types/Elf64_Half.h
new file mode 100644
index 0000000000000..4ef5591d5249a
--- /dev/null
+++ b/libc/hdr/types/Elf64_Half.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Half ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_HALF_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_HALF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Half.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_HALF_H
diff --git a/libc/hdr/types/Elf64_Lword.h b/libc/hdr/types/Elf64_Lword.h
new file mode 100644
index 0000000000000..8786880f73027
--- /dev/null
+++ b/libc/hdr/types/Elf64_Lword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Lword ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_LWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_LWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Lword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_LWORD_H
diff --git a/libc/hdr/types/Elf64_Nhdr.h b/libc/hdr/types/Elf64_Nhdr.h
new file mode 100644
index 0000000000000..165dc401924aa
--- /dev/null
+++ b/libc/hdr/types/Elf64_Nhdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Nhdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_NHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_NHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Nhdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_NHDR_H
diff --git a/libc/hdr/types/Elf64_Off.h b/libc/hdr/types/Elf64_Off.h
new file mode 100644
index 0000000000000..1828806a9eaa9
--- /dev/null
+++ b/libc/hdr/types/Elf64_Off.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Off -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_OFF_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_OFF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Off.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_OFF_H
diff --git a/libc/hdr/types/Elf64_Phdr.h b/libc/hdr/types/Elf64_Phdr.h
new file mode 100644
index 0000000000000..26ba03a25933a
--- /dev/null
+++ b/libc/hdr/types/Elf64_Phdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Phdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_PHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_PHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Phdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_PHDR_H
diff --git a/libc/hdr/types/Elf64_Rel.h b/libc/hdr/types/Elf64_Rel.h
new file mode 100644
index 0000000000000..01271e4cd5098
--- /dev/null
+++ b/libc/hdr/types/Elf64_Rel.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Rel -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_REL_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_REL_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Rel.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_REL_H
diff --git a/libc/hdr/types/Elf64_Rela.h b/libc/hdr/types/Elf64_Rela.h
new file mode 100644
index 0000000000000..aefd0a12229d6
--- /dev/null
+++ b/libc/hdr/types/Elf64_Rela.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Rela ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_RELA_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_RELA_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Rela.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_RELA_H
diff --git a/libc/hdr/types/Elf64_Shdr.h b/libc/hdr/types/Elf64_Shdr.h
new file mode 100644
index 0000000000000..8232191e633b5
--- /dev/null
+++ b/libc/hdr/types/Elf64_Shdr.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Shdr ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_SHDR_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_SHDR_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Shdr.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_SHDR_H
diff --git a/libc/hdr/types/Elf64_Sword.h b/libc/hdr/types/Elf64_Sword.h
new file mode 100644
index 0000000000000..e2396dcb95fe2
--- /dev/null
+++ b/libc/hdr/types/Elf64_Sword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Sword ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_SWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_SWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Sword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_SWORD_H
diff --git a/libc/hdr/types/Elf64_Sxword.h b/libc/hdr/types/Elf64_Sxword.h
new file mode 100644
index 0000000000000..a8cefb0b1028c
--- /dev/null
+++ b/libc/hdr/types/Elf64_Sxword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Sxword --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_SXWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_SXWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Sxword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_SXWORD_H
diff --git a/libc/hdr/types/Elf64_Sym.h b/libc/hdr/types/Elf64_Sym.h
new file mode 100644
index 0000000000000..f0129a008406a
--- /dev/null
+++ b/libc/hdr/types/Elf64_Sym.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Sym -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_SYM_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_SYM_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Sym.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_SYM_H
diff --git a/libc/hdr/types/Elf64_Verdaux.h b/libc/hdr/types/Elf64_Verdaux.h
new file mode 100644
index 0000000000000..5112b57e05eba
--- /dev/null
+++ b/libc/hdr/types/Elf64_Verdaux.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Verdaux -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_VERDAUX_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_VERDAUX_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Verdaux.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_VERDAUX_H
diff --git a/libc/hdr/types/Elf64_Verdef.h b/libc/hdr/types/Elf64_Verdef.h
new file mode 100644
index 0000000000000..18c55f3ce2480
--- /dev/null
+++ b/libc/hdr/types/Elf64_Verdef.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Verdef --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_VERDEF_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_VERDEF_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Verdef.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_VERDEF_H
diff --git a/libc/hdr/types/Elf64_Vernaux.h b/libc/hdr/types/Elf64_Vernaux.h
new file mode 100644
index 0000000000000..bd5bb38b0c982
--- /dev/null
+++ b/libc/hdr/types/Elf64_Vernaux.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Vernaux -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_VERNAUX_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_VERNAUX_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Vernaux.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_VERNAUX_H
diff --git a/libc/hdr/types/Elf64_Verneed.h b/libc/hdr/types/Elf64_Verneed.h
new file mode 100644
index 0000000000000..4ce8891b3bbc4
--- /dev/null
+++ b/libc/hdr/types/Elf64_Verneed.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Verneed -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_VERNEED_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_VERNEED_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Verneed.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_VERNEED_H
diff --git a/libc/hdr/types/Elf64_Versym.h b/libc/hdr/types/Elf64_Versym.h
new file mode 100644
index 0000000000000..cd06d0293effa
--- /dev/null
+++ b/libc/hdr/types/Elf64_Versym.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Versym --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_VERSYM_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_VERSYM_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Versym.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_VERSYM_H
diff --git a/libc/hdr/types/Elf64_Word.h b/libc/hdr/types/Elf64_Word.h
new file mode 100644
index 0000000000000..d8ebe52e0e967
--- /dev/null
+++ b/libc/hdr/types/Elf64_Word.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Word ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_WORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_WORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Word.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_WORD_H
diff --git a/libc/hdr/types/Elf64_Xword.h b/libc/hdr/types/Elf64_Xword.h
new file mode 100644
index 0000000000000..af9b183d5264b
--- /dev/null
+++ b/libc/hdr/types/Elf64_Xword.h
@@ -0,0 +1,23 @@
+
+//===-- Proxy for Elf64_Xword ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_ELF64_XWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF64_XWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf64_Xword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF64_XWORD_H
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index a76f15b95bcb8..2bb14802c2c0c 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -485,6 +485,11 @@ add_header_macro(
     .llvm-libc-types.Elf32_Off
     .llvm-libc-types.Elf32_Phdr
     .llvm-libc-types.Elf32_Sword
+    .llvm-libc-types.Elf32_Verdaux
+    .llvm-libc-types.Elf32_Verdef
+    .llvm-libc-types.Elf32_Vernaux
+    .llvm-libc-types.Elf32_Verneed
+    .llvm-libc-types.Elf32_Versym
     .llvm-libc-types.Elf32_Word
     .llvm-libc-types.Elf64_Addr
     .llvm-libc-types.Elf64_Ehdr
@@ -495,6 +500,11 @@ add_header_macro(
     .llvm-libc-types.Elf64_Phdr
     .llvm-libc-types.Elf64_Sword
     .llvm-libc-types.Elf64_Sxword
+    .llvm-libc-types.Elf64_Verdaux
+    .llvm-libc-types.Elf64_Verdef
+    .llvm-libc-types.Elf64_Vernaux
+    .llvm-libc-types.Elf64_Verneed
+    .llvm-libc-types.Elf64_Versym
     .llvm-libc-types.Elf64_Word
     .llvm-libc-types.Elf64_Xword
 )
diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index 1ad98b6794019..a3366a708b24c 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -3,8 +3,9 @@ header_template: elf.h.def
 standards:
   - svid
 macros:
+  # ELF Header
   - macro_name: EI_NIDENT
-    macro_header: elf-macros.h
+    macro_value: 16
   - macro_name: EI_MAG0
     macro_value: 0
   - macro_name: EI_MAG1
@@ -89,6 +90,159 @@ macros:
     macro_value: 0
   - macro_name: EV_CURRENT
     macro_value: 1
+  # Sections
+  - macro_name: SHN_UNDEF
+    macro_value: 0
+  - macro_name: SHN_LORESERVE
+    macro_value: '0xff00'
+  - macro_name: SHN_LOPROC
+    macro_value: '0xff00'
+  - macro_name: SHN_HIPROC
+    macro_value: '0xff1f'
+  - macro_name: SHN_LOOS
+    macro_value: '0xff20'
+  - macro_name: SHN_HIOS
+    macro_value: '0xff3f'
+  - macro_name: SHN_ABS
+    macro_value: '0xfff1'
+  - macro_name: SHN_COMMON
+    macro_value: '0xfff2'
+  - macro_name: SHN_XINDEX
+    macro_value: '0xffff'
+  - macro_name: SHN_HIRESERVE
+    macro_value: '0xffff'
+  - macro_name: SHT_NULL
+    macro_value: 0
+  - macro_name: SHT_PROGBITS
+    macro_value: 1
+  - macro_name: SHT_SYMTAB
+    macro_value: 2
+  - macro_name: SHT_STRTAB
+    macro_value: 3
+  - macro_name: SHT_RELA
+    macro_value: 4
+  - macro_name: SHT_HASH
+    macro_value: 5
+  - macro_name: SHT_DYNAMIC
+    macro_value: 6
+  - macro_name: SHT_NOTE
+    macro_value: 7
+  - macro_name: SHT_NOBITS
+    macro_value: 8
+  - macro_name: SHT_REL
+    macro_value: 9
+  - macro_name: SHT_SHLIB
+    macro_value: 10
+  - macro_name: SHT_DYNSYM
+    macro_value: 11
+  - macro_name: SHT_INIT_ARRAY
+    macro_value: 14
+  - macro_name: SHT_FINI_ARRAY
+    macro_value: 15
+  - macro_name: SHT_PREINIT_ARRAY
+    macro_value: 16
+  - macro_name: SHT_GROUP
+    macro_value: 17
+  - macro_name: SHT_SYMTAB_SHNDX
+    macro_value: 18
+  - macro_name: SHT_LOOS
+    macro_value: '0x60000000'
+  - macro_name: SHT_HIOS
+    macro_value: '0x6fffffff'
+  - macro_name: SHT_LOPROC
+    macro_value: '0x70000000'
+  - macro_name: SHT_HIPROC
+    macro_value: '0x7fffffff'
+  - macro_name: SHT_LOUSER
+    macro_value: '0x80000000'
+  - macro_name: SHT_HIUSER
+    macro_value: '0xffffffff'
+  - macro_name: SHF_WRITE
+    macro_value: '0x1'
+  - macro_name: SHF_ALLOC
+    macro_value: '0x2'
+  - macro_name: SHF_EXECINSTR
+    macro_value: '0x4'
+  - macro_name: SHF_MERGE
+    macro_value: '0x10'
+  - macro_name: SHF_STRINGS
+    macro_value: '0x20'
+  - macro_name: SHF_INFO_LINK
+    macro_value: '0x40'
+  - macro_name: SHF_LINK_ORDER
+    macro_value: '0x80'
+  - macro_name: SHF_OS_NONCONFORMING
+    macro_value: '0x100'
+  - macro_name: SHF_GROUP
+    macro_value: '0x200'
+  - macro_name: SHF_TLS
+    macro_value: '0x400'
+  - macro_name: SHF_COMPRESSED
+    macro_value: '0x800'
+  - macro_name: SHF_MASKOS
+    macro_value: '0x0ff00000'
+  - macro_name: SHF_MASKPROC
+    macro_value: '0xf0000000'
+  - macro_name: ELFCOMPRESS_ZLIB
+    macro_value: 1
+  - macro_name: ELFCOMPRESS_ZSTD
+    macro_value: 2
+  - macro_name: ELFCOMPRESS_LOOS
+    macro_value: '0x60000000'
+  - macro_name: ELFCOMPRESS_HIOS
+    macro_value: '0x6fffffff'
+  - macro_name: ELFCOMPRESS_LOPROC
+    macro_value: '0x70000000'
+  - macro_name: ELFCOMPRESS_HIPROC
+    macro_value: '0x7fffffff'
+  # Symbol Table
+  - macro_name: STN_UNDEF
+    macro_value: 0
+  - macro_name: STB_LOCAL
+    macro_value: 0
+  - macro_name: STB_GLOBAL
+    macro_value: 1
+  - macro_name: STB_WEAK
+    macro_value: 2
+  - macro_name: STB_LOOS
+    macro_value: 10
+  - macro_name: STB_HIOS
+    macro_value: 12
+  - macro_name: STB_LOPROC
+    macro_value: 13
+  - macro_name: STB_HIPROC
+    macro_value: 15
+  - macro_name: STT_NOTYPE
+    macro_value: 0
+  - macro_name: STT_OBJECT
+    macro_value: 1
+  - macro_name: STT_FUNC
+    macro_value: 2
+  - macro_name: STT_SECTION
+    macro_value: 3
+  - macro_name: STT_FILE
+    macro_value: 4
+  - macro_name: STT_COMMON
+    macro_value: 5
+  - macro_name: STT_TLS
+    macro_value: 6
+  - macro_name: STT_LOOS
+    macro_value: 10
+  - macro_name: STT_HIOS
+    macro_value: 12
+  - macro_name: STT_LOPROC
+    macro_value: 13
+  - macro_name: STT_HIPROC
+    macro_value: 15
+  - macro_name: STV_DEFAULT
+    macro_value: 0
+  - macro_name: STV_INTERNAL
+    macro_value: 1
+  - macro_name: STV_HIDDEN
+    macro_value: 2
+  - macro_name: STV_PROTECTED
+    macro_value: 3
+  # Program Loading
   - macro_name: PT_NULL
     macro_value: 0
   - macro_name: PT_LOAD
@@ -123,36 +277,148 @@ macros:
     macro_value: '0x0ff00000'
   - macro_name: PF_MASKPROC
     macro_value: '0xf0000000'
+  # Dynamic Linking
+  - macro_name: DT_NULL
+    macro_value: 0
+  - macro_name: DT_NEEDED
+    macro_value: 1
+  - macro_name: DT_PLTRELSZ
+    macro_value: 2
+  - macro_name: DT_PLTGOT
+    macro_value: 3
+  - macro_name: DT_HASH
+    macro_value: 4
+  - macro_name: DT_STRTAB
+    macro_value: 5
+  - macro_name: DT_SYMTAB
+    macro_value: 6
+  - macro_name: DT_RELA
+    macro_value: 7
+  - macro_name: DT_RELASZ
+    macro_value: 8
+  - macro_name: DT_RELAENT
+    macro_value: 9
+  - macro_name: DT_STRSZ
+    macro_value: 10
+  - macro_name: DT_SYMENT
+    macro_value: 11
+  - macro_name: DT_INIT
+    macro_value: 12
+  - macro_name: DT_FINI
+    macro_value: 13
+  - macro_name: DT_SONAME
+    macro_value: 14
+  - macro_name: DT_RPATH
+    macro_value: 15
+  - macro_name: DT_SYMBOLIC
+    macro_value: 16
+  - macro_name: DT_REL
+    macro_value: 17
+  - macro_name: DT_RELSZ
+    macro_value: 18
+  - macro_name: DT_RELENT
+    macro_value: 19
+  - macro_name: DT_PLTREL
+    macro_value: 20
+  - macro_name: DT_DEBUG
+    macro_value: 21
+  - macro_name: DT_TEXTREL
+    macro_value: 22
+  - macro_name: DT_JMPREL
+    macro_value: 23
+  - macro_name: DT_BIND_NOW*
+    macro_value: 24
+  - macro_name: DT_INIT_ARRAY
+    macro_value: 25
+  - macro_name: DT_FINI_ARRAY
+    macro_value: 26
+  - macro_name: DT_INIT_ARRAYSZ
+    macro_value: 27
+  - macro_name: DT_FINI_ARRAYSZ
+    macro_value: 28
+  - macro_name: DT_RUNPATH
+    macro_value: 29
+  - macro_name: DT_FLAGS
+    macro_value: 30
+  - macro_name: DT_ENCODING
+    macro_value: 32
+  - macro_name: DT_PREINIT_ARRAY
+    macro_value: 32
+  - macro_name: DT_PREINIT_ARRAYSZ
+    macro_value: 33
+  - macro_name: DT_SYMTAB_SHNDX
+    macro_value: 34
+  - macro_name: DT_LOOS
+    macro_value: '0x6000000D'
+  - macro_name: DT_HIOS
+    macro_value: '0x6ffff000'
+  - macro_name: DT_LOPROC
+    macro_value: '0x70000000'
+  - macro_name: DT_HIPROC
+    macro_value: '0x7fffffff'
+  - macro_name: DF_ORIGIN
+    macro_value: '0x1'
+  - macro_name: DF_SYMBOLIC
+    macro_value: '0x2'
+  - macro_name: DF_TEXTREL
+    macro_value: '0x4'
+  - macro_name: DF_BIND_NOW
+    macro_value: '0x8'
+  - macro_name: DF_STATIC_TLS
+    macro_value: '0x10'
   # Notes used in ET_CORE.
   - macro_name: NT_PRSTATUS
     macro_value: 1
-    standards:
-      - linux
   - macro_name: NT_PRFPREG
     macro_value: 2
-    standards:
-      - linux
   - macro_name: NT_PRPSINFO
     macro_value: 3
-    standards:
-      - linux
   - macro_name: NT_TASKSTRUCT
     macro_value: 4
-    standards:
-      - linux
   - macro_name: NT_PLATFORM
     macro_value: 5
-    standards:
-      - linux
   - macro_name: NT_AUXV
     macro_value: 6
-    standards:
-      - linux
   # Notes used by GNU toolchain.
+  - macro_name: NT_GNU_ABI_TAG
+    macro_value: 1
+    standards:
+      - gnu
+  - macro_name: NT_GNU_HWCAP
+    macro_value: 2
+    standards:
+      - gnu
   - macro_name: NT_GNU_BUILD_ID
     macro_value: 3
     standards:
       - gnu
+  - macro_name: NT_GNU_GOLD_VERSION
+    macro_value: 4
+    standards:
+      - gnu
+  - macro_name: NT_GNU_PROPERTY_TYPE_0
+    macro_value: 5
+    standards:
+      - gnu
+  # Symbol Versioning
+  - macro_name: VER_DEF_NONE
+    macro_value: 0
+  - macro_name: VER_DEF_CURRENT
+    macro_value: 1
+  - macro_name: VER_DEF_NUM
+    macro_value: 2
+  - macro_name: VER_FLG_BASE
+    macro_value: '0x1'
+  - macro_name: VER_FLG_WEAK
+    macro_value: '0x2'
+  - macro_name: VER_NDX_LOCAL
+    macro_value: 0
+  - macro_name: VER_NDX_GLOBAL
+    macro_value: 1
+  - macro_name: VER_NDX_LORESERVE
+    macro_value: '0xff00'
+  - macro_name: VER_NDX_ELIMINATE
+    macro_value: '0xff01'
 types:
   - type_name: Elf32_Addr
   - type_name: Elf32_Half
@@ -169,6 +435,11 @@ types:
   - type_name: Elf32_Rela
   - type_name: Elf32_Shdr
   - type_name: Elf32_Sym
+  - type_name: Elf32_Verdaux
+  - type_name: Elf32_Verdef
+  - type_name: Elf32_Vernaux
+  - type_name: Elf32_Verneed
+  - type_name: Elf32_Versym
   - type_name: Elf64_Addr
   - type_name: Elf64_Half
   - type_name: Elf64_Off
@@ -186,6 +457,11 @@ types:
   - type_name: Elf64_Rela
   - type_name: Elf64_Shdr
   - type_name: Elf64_Sym
+  - type_name: Elf64_Verdaux
+  - type_name: Elf64_Verdef
+  - type_name: Elf64_Vernaux
+  - type_name: Elf64_Verneed
+  - type_name: Elf64_Versym
 enums: []
 objects: []
 functions: []
diff --git a/libc/include/link.h.def b/libc/include/link.h.def
new file mode 100644
index 0000000000000..b9c83e87751b6
--- /dev/null
+++ b/libc/include/link.h.def
@@ -0,0 +1,19 @@
+//===-- System V header link.h --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_LINK_H
+#define LLVM_LIBC_LINK_H
+
+#include "__llvm-libc-common.h"
+#include "llvm-libc-macros/link-macros.h"
+
+#include <elf.h>
+
+%%public_api()
+
+#endif // LLVM_LIBC_LINK_H
diff --git a/libc/include/link.yaml b/libc/include/link.yaml
index 7e303a4436d83..b917bc0a61ae9 100644
--- a/libc/include/link.yaml
+++ b/libc/include/link.yaml
@@ -1,4 +1,5 @@
 header: link.h
+header_template: link.h.def
 standards:
   - svid
 macros:
diff --git a/libc/include/llvm-libc-macros/elf-macros.h b/libc/include/llvm-libc-macros/elf-macros.h
index fffcbb62527a7..6857b6681bfa2 100644
--- a/libc/include/llvm-libc-macros/elf-macros.h
+++ b/libc/include/llvm-libc-macros/elf-macros.h
@@ -9,6 +9,27 @@
 #ifndef LLVM_LIBC_MACROS_ELF_MACROS_H
 #define LLVM_LIBC_MACROS_ELF_MACROS_H
 
-#define EI_NIDENT 16
+// Symbol Table
+
+#define ELF32_ST_BIND(i) ((i) >> 4)
+#define ELF32_ST_TYPE(i) ((i) & 0xf)
+#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf))
+
+#define ELF64_ST_BIND(i) ((i) >> 4)
+#define ELF64_ST_TYPE(i) ((i) & 0xf)
+#define ELF64_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf))
+
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x3)
+#define ELF64_ST_VISIBILITY(o) ((o) & 0x3)
+
+// Relocations
+
+#define ELF32_R_SYM(i) ((i) >> 8)
+#define ELF32_R_TYPE(i) ((unsigned char)(i))
+#define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t))
+
+#define ELF64_R_SYM(i) ((i) >> 32)
+#define ELF64_R_TYPE(i) ((i) & 0xffffffffL)
+#define ELF64_R_INFO(s, t) (((s) << 32) + ((t) & 0xffffffffL))
 
 #endif // LLVM_LIBC_MACROS_ELF_MACROS_H
diff --git a/libc/include/llvm-libc-macros/link-macros.h b/libc/include/llvm-libc-macros/link-macros.h
index 89e7bb50aa556..1876a6dc848d1 100644
--- a/libc/include/llvm-libc-macros/link-macros.h
+++ b/libc/include/llvm-libc-macros/link-macros.h
@@ -9,7 +9,38 @@
 #ifndef LLVM_LIBC_MACROS_LINK_MACROS_H
 #define LLVM_LIBC_MACROS_LINK_MACROS_H
 
-#include "elf-macros.h"
+#include "../llvm-libc-types/Elf32_Addr.h"
+#include "../llvm-libc-types/Elf32_Chdr.h"
+#include "../llvm-libc-types/Elf32_Dyn.h"
+#include "../llvm-libc-types/Elf32_Ehdr.h"
+#include "../llvm-libc-types/Elf32_Half.h"
+#include "../llvm-libc-types/Elf32_Lword.h"
+#include "../llvm-libc-types/Elf32_Nhdr.h"
+#include "../llvm-libc-types/Elf32_Off.h"
+#include "../llvm-libc-types/Elf32_Phdr.h"
+#include "../llvm-libc-types/Elf32_Rel.h"
+#include "../llvm-libc-types/Elf32_Rela.h"
+#include "../llvm-libc-types/Elf32_Shdr.h"
+#include "../llvm-libc-types/Elf32_Sword.h"
+#include "../llvm-libc-types/Elf32_Sym.h"
+#include "../llvm-libc-types/Elf32_Word.h"
+#include "../llvm-libc-types/Elf64_Addr.h"
+#include "../llvm-libc-types/Elf64_Chdr.h"
+#include "../llvm-libc-types/Elf64_Dyn.h"
+#include "../llvm-libc-types/Elf64_Ehdr.h"
+#include "../llvm-libc-types/Elf64_Half.h"
+#include "../llvm-libc-types/Elf64_Lword.h"
+#include "../llvm-libc-types/Elf64_Nhdr.h"
+#include "../llvm-libc-types/Elf64_Off.h"
+#include "../llvm-libc-types/Elf64_Phdr.h"
+#include "../llvm-libc-types/Elf64_Rel.h"
+#include "../llvm-libc-types/Elf64_Rela.h"
+#include "../llvm-libc-types/Elf64_Shdr.h"
+#include "../llvm-libc-types/Elf64_Sword.h"
+#include "../llvm-libc-types/Elf64_Sxword.h"
+#include "../llvm-libc-types/Elf64_Sym.h"
+#include "../llvm-libc-types/Elf64_Word.h"
+#include "../llvm-libc-types/Elf64_Xword.h"
 
 #ifdef __LP64__
 #define ElfW(type) Elf64_##type
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index cb2c2b243c964..569d32c8937aa 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -215,7 +215,6 @@ add_header(
   HDR
     Elf32_Ehdr.h
   DEPENDS
-    libc.include.llvm-libc-macros.elf_macros
     .Elf32_Addr
     .Elf32_Half
     .Elf32_Off
@@ -266,6 +265,44 @@ add_header(
     .Elf32_Half
     .Elf32_Word
 )
+add_header(
+  Elf32_Verdaux
+  HDR
+    Elf32_Verdaux.h
+  DEPENDS
+    .Elf32_Word
+)
+add_header(
+  Elf32_Verdef
+  HDR
+    Elf32_Verdaux.h
+  DEPENDS
+    .Elf32_Half
+    .Elf32_Word
+)
+add_header(
+  Elf32_Vernaux
+  HDR
+    Elf32_Vernaux.h
+  DEPENDS
+    .Elf32_Half
+    .Elf32_Word
+)
+add_header(
+  Elf32_Verneed
+  HDR
+    Elf32_Verneed.h
+  DEPENDS
+    .Elf32_Half
+    .Elf32_Word
+)
+add_header(
+  Elf32_Versym
+  HDR
+    Elf32_Versym.h
+  DEPENDS
+  .Elf32_Half
+)
 
 add_header(Elf64_Addr HDR Elf64_Addr.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf64_Half HDR Elf64_Half.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
@@ -298,7 +335,6 @@ add_header(
   HDR
     Elf64_Ehdr.h
   DEPENDS
-    libc.include.llvm-libc-macros.elf_macros
     .Elf64_Addr
     .Elf64_Half
     .Elf64_Off
@@ -352,6 +388,44 @@ add_header(
     .Elf64_Word
     .Elf64_Xword
 )
+add_header(
+  Elf64_Verdaux
+  HDR
+    Elf64_Verdaux.h
+  DEPENDS
+    .Elf64_Word
+)
+add_header(
+  Elf64_Verdef
+  HDR
+    Elf64_Verdaux.h
+  DEPENDS
+    .Elf64_Half
+    .Elf64_Word
+)
+add_header(
+  Elf64_Vernaux
+  HDR
+    Elf64_Vernaux.h
+  DEPENDS
+    .Elf64_Half
+    .Elf64_Word
+)
+add_header(
+  Elf64_Verneed
+  HDR
+    Elf64_Verneed.h
+  DEPENDS
+    .Elf64_Half
+    .Elf64_Word
+)
+add_header(
+  Elf64_Versym
+  HDR
+    Elf64_Versym.h
+  DEPENDS
+  .Elf64_Half
+)
 
 # UEFI
 add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
diff --git a/libc/include/llvm-libc-types/Elf32_Dyn.h b/libc/include/llvm-libc-types/Elf32_Dyn.h
index f3539be1d77eb..0871bb0311fc3 100644
--- a/libc/include/llvm-libc-types/Elf32_Dyn.h
+++ b/libc/include/llvm-libc-types/Elf32_Dyn.h
@@ -21,4 +21,4 @@ typedef struct {
   } d_un;
 } Elf32_Dyn;
 
-#endif // NLLVM_LIBC_TYPES_ELF32_DYN_H
+#endif // LLVM_LIBC_TYPES_ELF32_DYN_H
diff --git a/libc/include/llvm-libc-types/Elf32_Ehdr.h b/libc/include/llvm-libc-types/Elf32_Ehdr.h
index 571b234a6ff6b..ee2e09ba5a57c 100644
--- a/libc/include/llvm-libc-types/Elf32_Ehdr.h
+++ b/libc/include/llvm-libc-types/Elf32_Ehdr.h
@@ -9,12 +9,13 @@
 #ifndef LLVM_LIBC_TYPES_ELF32_EHDR_H
 #define LLVM_LIBC_TYPES_ELF32_EHDR_H
 
-#include "../llvm-libc-macros/elf-macros.h"
 #include "Elf32_Addr.h"
 #include "Elf32_Half.h"
 #include "Elf32_Off.h"
 #include "Elf32_Word.h"
 
+#define EI_NIDENT 16
+
 typedef struct {
   unsigned char e_ident[EI_NIDENT];
   Elf32_Half e_type;
diff --git a/libc/include/llvm-libc-types/Elf32_Verdaux.h b/libc/include/llvm-libc-types/Elf32_Verdaux.h
new file mode 100644
index 0000000000000..6b0ab6d306ed6
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Verdaux.h
@@ -0,0 +1,19 @@
+//===-- Definition of Elf32_Verdaux type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_VERDAUX_H
+#define LLVM_LIBC_TYPES_ELF32_VERDAUX_H
+
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word vda_name;
+  Elf32_Word vda_next;
+} Elf32_Verdaux;
+
+#endif // LLVM_LIBC_TYPES_ELF32_VERDAUX_H
diff --git a/libc/include/llvm-libc-types/Elf32_Verdef.h b/libc/include/llvm-libc-types/Elf32_Verdef.h
new file mode 100644
index 0000000000000..9030eb38173d3
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Verdef.h
@@ -0,0 +1,25 @@
+//===-- Definition of Elf32_Verdef type -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_VERDEF_H
+#define LLVM_LIBC_TYPES_ELF32_VERDEF_H
+
+#include "Elf32_Half.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Half vd_version;
+  Elf32_Half vd_flags;
+  Elf32_Half vd_ndx;
+  Elf32_Half vd_cnt;
+  Elf32_Word vd_hash;
+  Elf32_Word vd_aux;
+  Elf32_Word vd_next;
+} Elf32_Verdef;
+
+#endif // LLVM_LIBC_TYPES_ELF32_VERDEF_H
diff --git a/libc/include/llvm-libc-types/Elf32_Vernaux.h b/libc/include/llvm-libc-types/Elf32_Vernaux.h
new file mode 100644
index 0000000000000..0268882f2d094
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Vernaux.h
@@ -0,0 +1,23 @@
+//===-- Definition of Elf32_Vernaux type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_VERNAUX_H
+#define LLVM_LIBC_TYPES_ELF32_VERNAUX_H
+
+#include "Elf32_Half.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Word vna_hash;
+  Elf32_Half vna_flags;
+  Elf32_Half vna_other;
+  Elf32_Word vna_name;
+  Elf32_Word vna_next;
+} Elf32_Vernaux;
+
+#endif // NLLVM_LIBC_TYPES_ELF32_VERNAUX_H
diff --git a/libc/include/llvm-libc-types/Elf32_Verneed.h b/libc/include/llvm-libc-types/Elf32_Verneed.h
new file mode 100644
index 0000000000000..a76fc69caf7bd
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Verneed.h
@@ -0,0 +1,23 @@
+//===-- Definition of Elf32_Verneed type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_VERNEED_H
+#define LLVM_LIBC_TYPES_ELF32_VERNEED_H
+
+#include "Elf32_Half.h"
+#include "Elf32_Word.h"
+
+typedef struct {
+  Elf32_Half vn_version;
+  Elf32_Half vn_cnt;
+  Elf32_Word vn_file;
+  Elf32_Word vn_aux;
+  Elf32_Word vn_next;
+} Elf32_Verneed;
+
+#endif // LLVM_LIBC_TYPES_ELF32_VERNEED_H
diff --git a/libc/include/llvm-libc-types/Elf32_Versym.h b/libc/include/llvm-libc-types/Elf32_Versym.h
new file mode 100644
index 0000000000000..e5930a1018eb5
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Versym.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_Versym type -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF32_VERSYM_H
+#define LLVM_LIBC_TYPES_ELF32_VERSYM_H
+
+#include "Elf32_Half.h"
+
+typedef Elf32_Half Elf32_Versym;
+
+#endif // NLLVM_LIBC_TYPES_ELF32_VERSYM_H
diff --git a/libc/include/llvm-libc-types/Elf64_Ehdr.h b/libc/include/llvm-libc-types/Elf64_Ehdr.h
index 59bea9c302f51..d57ee5fa4536f 100644
--- a/libc/include/llvm-libc-types/Elf64_Ehdr.h
+++ b/libc/include/llvm-libc-types/Elf64_Ehdr.h
@@ -9,12 +9,13 @@
 #ifndef LLVM_LIBC_TYPES_ELF64_EHDR_H
 #define LLVM_LIBC_TYPES_ELF64_EHDR_H
 
-#include "../llvm-libc-macros/elf-macros.h"
 #include "Elf64_Addr.h"
 #include "Elf64_Half.h"
 #include "Elf64_Off.h"
 #include "Elf64_Word.h"
 
+#define EI_NIDENT 16
+
 typedef struct {
   unsigned char e_ident[EI_NIDENT];
   Elf64_Half e_type;
diff --git a/libc/include/llvm-libc-types/Elf64_Verdaux.h b/libc/include/llvm-libc-types/Elf64_Verdaux.h
new file mode 100644
index 0000000000000..bdfa5f66e0e9f
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Verdaux.h
@@ -0,0 +1,19 @@
+//===-- Definition of Elf64_Verdaux type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_VERDAUX_H
+#define LLVM_LIBC_TYPES_ELF64_VERDAUX_H
+
+#include "Elf64_Word.h"
+
+typedef struct {
+  Elf64_Word vda_name;
+  Elf64_Word vda_next;
+} Elf64_Verdaux;
+
+#endif // LLVM_LIBC_TYPES_ELF64_VERDAUX_H
diff --git a/libc/include/llvm-libc-types/Elf64_Verdef.h b/libc/include/llvm-libc-types/Elf64_Verdef.h
new file mode 100644
index 0000000000000..9c1823f387620
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Verdef.h
@@ -0,0 +1,25 @@
+//===-- Definition of Elf64_Verdef type -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_VERDEF_H
+#define LLVM_LIBC_TYPES_ELF64_VERDEF_H
+
+#include "Elf64_Half.h"
+#include "Elf64_Word.h"
+
+typedef struct {
+  Elf64_Half vd_version;
+  Elf64_Half vd_flags;
+  Elf64_Half vd_ndx;
+  Elf64_Half vd_cnt;
+  Elf64_Word vd_hash;
+  Elf64_Word vd_aux;
+  Elf64_Word vd_next;
+} Elf64_Verdef;
+
+#endif // LLVM_LIBC_TYPES_ELF64_VERDEF_H
diff --git a/libc/include/llvm-libc-types/Elf64_Vernaux.h b/libc/include/llvm-libc-types/Elf64_Vernaux.h
new file mode 100644
index 0000000000000..f88eb1e20d916
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Vernaux.h
@@ -0,0 +1,23 @@
+//===-- Definition of Elf64_Vernaux type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_VERNAUX_H
+#define LLVM_LIBC_TYPES_ELF64_VERNAUX_H
+
+#include "Elf64_Half.h"
+#include "Elf64_Word.h"
+
+typedef struct {
+  Elf64_Word vna_hash;
+  Elf64_Half vna_flags;
+  Elf64_Half vna_other;
+  Elf64_Word vna_name;
+  Elf64_Word vna_next;
+} Elf64_Vernaux;
+
+#endif // NLLVM_LIBC_TYPES_ELF64_VERNAUX_H
diff --git a/libc/include/llvm-libc-types/Elf64_Verneed.h b/libc/include/llvm-libc-types/Elf64_Verneed.h
new file mode 100644
index 0000000000000..2edfec59525bd
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Verneed.h
@@ -0,0 +1,23 @@
+//===-- Definition of Elf64_Verneed type ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_VERNEED_H
+#define LLVM_LIBC_TYPES_ELF64_VERNEED_H
+
+#include "Elf64_Half.h"
+#include "Elf64_Word.h"
+
+typedef struct {
+  Elf64_Half vn_version;
+  Elf64_Half vn_cnt;
+  Elf64_Word vn_file;
+  Elf64_Word vn_aux;
+  Elf64_Word vn_next;
+} Elf64_Verneed;
+
+#endif // LLVM_LIBC_TYPES_ELF64_VERNEED_H
diff --git a/libc/include/llvm-libc-types/Elf64_Versym.h b/libc/include/llvm-libc-types/Elf64_Versym.h
new file mode 100644
index 0000000000000..b3057386514e6
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf64_Versym.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf64_Versym type -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_ELF64_VERSYM_H
+#define LLVM_LIBC_TYPES_ELF64_VERSYM_H
+
+#include "Elf64_Half.h"
+
+typedef Elf64_Half Elf64_Versym;
+
+#endif // NLLVM_LIBC_TYPES_ELF64_VERSYM_H
diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt
index 0a6037757f5a4..c73c38c3f6f4a 100644
--- a/libc/src/__support/OSUtil/linux/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt
@@ -71,9 +71,28 @@ add_object_library(
     libc.src.__support.threads.callonce
     libc.src.__support.threads.linux.futex_word_type
     libc.src.__support.OSUtil.linux.auxv
-    libc.hdr.types.struct_timeval
-    libc.hdr.types.struct_timespec
+    libc.hdr.link_macros
+    libc.hdr.sys_auxv_macros
+    libc.hdr.types.Elf32_Addr
+    libc.hdr.types.Elf32_Dyn
+    libc.hdr.types.Elf32_Ehdr
+    libc.hdr.types.Elf32_Phdr
+    libc.hdr.types.Elf32_Shdr
+    libc.hdr.types.Elf32_Sym
+    libc.hdr.types.Elf32_Verdaux
+    libc.hdr.types.Elf32_Verdef
+    libc.hdr.types.Elf32_Versym
+    libc.hdr.types.Elf64_Addr
+    libc.hdr.types.Elf64_Dyn
+    libc.hdr.types.Elf64_Ehdr
+    libc.hdr.types.Elf64_Phdr
+    libc.hdr.types.Elf64_Shdr
+    libc.hdr.types.Elf64_Sym
+    libc.hdr.types.Elf64_Verdaux
+    libc.hdr.types.Elf64_Verdef
+    libc.hdr.types.Elf64_Versym
     libc.hdr.types.clockid_t
+    libc.hdr.types.struct_timespec
+    libc.hdr.types.struct_timeval
     libc.hdr.types.time_t
-    libc.hdr.link_macros
 )
diff --git a/libc/src/__support/OSUtil/linux/vdso.cpp b/libc/src/__support/OSUtil/linux/vdso.cpp
index d6fd3f3312594..deff75f337bd7 100644
--- a/libc/src/__support/OSUtil/linux/vdso.cpp
+++ b/libc/src/__support/OSUtil/linux/vdso.cpp
@@ -8,13 +8,30 @@
 #include "src/__support/OSUtil/linux/vdso.h"
 #include "hdr/link_macros.h"
 #include "hdr/sys_auxv_macros.h"
+#include "hdr/types/Elf32_Addr.h"
+#include "hdr/types/Elf32_Dyn.h"
+#include "hdr/types/Elf32_Ehdr.h"
+#include "hdr/types/Elf32_Phdr.h"
+#include "hdr/types/Elf32_Shdr.h"
+#include "hdr/types/Elf32_Sym.h"
+#include "hdr/types/Elf32_Verdaux.h"
+#include "hdr/types/Elf32_Verdef.h"
+#include "hdr/types/Elf32_Versym.h"
+#include "hdr/types/Elf64_Addr.h"
+#include "hdr/types/Elf64_Dyn.h"
+#include "hdr/types/Elf64_Ehdr.h"
+#include "hdr/types/Elf64_Phdr.h"
+#include "hdr/types/Elf64_Shdr.h"
+#include "hdr/types/Elf64_Sym.h"
+#include "hdr/types/Elf64_Verdaux.h"
+#include "hdr/types/Elf64_Verdef.h"
+#include "hdr/types/Elf64_Versym.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/CPP/string_view.h"
 #include "src/__support/OSUtil/linux/auxv.h"
 #include "src/__support/threads/callonce.h"
 #include "src/__support/threads/linux/futex_word.h"
-#include <linux/auxvec.h>
 
 // TODO: This is a temporary workaround to avoid including elf.h
 // Include our own headers for ElfW and friends once we have them.
@@ -26,35 +43,10 @@ Symbol::VDSOArray Symbol::global_cache{};
 CallOnceFlag Symbol::once_flag = callonce_impl::NOT_CALLED;
 
 namespace {
-// See https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/symverdefs.html
-struct Verdaux {
-  ElfW(Word) vda_name; /* Version or dependency names */
-  ElfW(Word) vda_next; /* Offset in bytes to next verdaux
-                          entry */
-};
-struct Verdef {
-  ElfW(Half) vd_version; /* Version revision */
-  ElfW(Half) vd_flags;   /* Version information */
-  ElfW(Half) vd_ndx;     /* Version Index */
-  ElfW(Half) vd_cnt;     /* Number of associated aux entries */
-  ElfW(Word) vd_hash;    /* Version name hash value */
-  ElfW(Word) vd_aux;     /* Offset in bytes to verdaux array */
-  ElfW(Word) vd_next;    /* Offset in bytes to next verdef entry */
-  Verdef *next() const {
-    if (vd_next == 0)
-      return nullptr;
-    return reinterpret_cast<Verdef *>(reinterpret_cast<uintptr_t>(this) +
-                                      vd_next);
-  }
-  Verdaux *aux() const {
-    return reinterpret_cast<Verdaux *>(reinterpret_cast<uintptr_t>(this) +
-                                       vd_aux);
-  }
-};
 
 // version search procedure specified by
 // https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/symversion.html#SYMVERTBL
-cpp::string_view find_version(Verdef *verdef, ElfW(Half) * versym,
+cpp::string_view find_version(ElfW(Verdef) * verdef, ElfW(Half) * versym,
                               const char *strtab, size_t idx) {
 #ifndef VER_FLG_BASE
   constexpr ElfW(Half) VER_FLG_BASE = 0x1;
@@ -63,7 +55,10 @@ cpp::string_view find_version(Verdef *verdef, ElfW(Half) * versym,
     return "";
   ElfW(Half) identifier = versym[idx] & 0x7FFF;
   // iterate through all version definitions
-  for (Verdef *def = verdef; def != nullptr; def = def->next()) {
+
+  for (ElfW(Verdef) *def = verdef; def != nullptr;
+       def = reinterpret_cast<ElfW(Verdef) *>(reinterpret_cast<uintptr_t>(def) +
+                                              def->vd_next)) {
     // skip if this is a file-level version
     if (def->vd_flags & VER_FLG_BASE)
       continue;
@@ -71,7 +66,8 @@ cpp::string_view find_version(Verdef *verdef, ElfW(Half) * versym,
     // whether the symbol is local. Only lower 15 bits are used for version
     // identifier.
     if ((def->vd_ndx & 0x7FFF) == identifier) {
-      Verdaux *aux = def->aux();
+      ElfW(Verdaux) *aux = reinterpret_cast<ElfW(Verdaux) *>(
+          reinterpret_cast<uintptr_t>(def) + def->vd_aux);
       return strtab + aux->vda_name;
     }
   }
@@ -96,8 +92,8 @@ struct VDSOSymbolTable {
   const char *strtab;
   ElfW(Sym) * symtab;
   // The following can be nullptr if the vDSO does not have versioning
-  ElfW(Half) * versym;
-  Verdef *verdef;
+  ElfW(Versym) * versym;
+  ElfW(Verdef) * verdef;
 
   void populate_symbol_cache(Symbol::VDSOArray &symbol_table,
                              size_t symbol_count, ElfW(Addr) vdso_addr) {
@@ -155,8 +151,8 @@ struct PhdrInfo {
   cpp::optional<VDSOSymbolTable> populate_symbol_table() {
     const char *strtab = nullptr;
     ElfW(Sym) *symtab = nullptr;
-    ElfW(Half) *versym = nullptr;
-    Verdef *verdef = nullptr;
+    ElfW(Versym) *versym = nullptr;
+    ElfW(Verdef) *verdef = nullptr;
     for (ElfW(Dyn) *d = vdso_dyn; d->d_tag != DT_NULL; ++d) {
       switch (d->d_tag) {
       case DT_STRTAB:
@@ -169,7 +165,7 @@ struct PhdrInfo {
         versym = reinterpret_cast<uint16_t *>(vdso_addr + d->d_un.d_ptr);
         break;
       case DT_VERDEF:
-        verdef = reinterpret_cast<Verdef *>(vdso_addr + d->d_un.d_ptr);
+        verdef = reinterpret_cast<ElfW(Verdef) *>(vdso_addr + d->d_un.d_ptr);
         break;
       }
       if (strtab && symtab && versym && verdef)
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index df2c4b9ec508c..60deb4c8b1942 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -97,15 +97,19 @@ add_object_library(
   DEPENDS
     libc.config.app_h
     libc.hdr.stdint_proxy
+    libc.hdr.types.Elf32_Phdr
+    libc.hdr.types.Elf64_Phdr
+    libc.hdr.types.Elf32_Dyn
+    libc.hdr.types.Elf64_Dyn
+    libc.include.llvm-libc-macros.link_macros
     libc.include.sys_mman
     libc.include.sys_syscall
-    libc.include.llvm-libc-macros.link_macros
-    libc.src.__support.threads.thread
+    libc.src.__support.OSUtil.linux.auxv
     libc.src.__support.OSUtil.osutil
+    libc.src.__support.threads.thread
     libc.src.stdlib.exit
     libc.src.stdlib.atexit
     libc.src.unistd.environ
-    libc.src.__support.OSUtil.linux.auxv
   COMPILE_OPTIONS
     -ffreestanding       # To avoid compiler warnings about calling the main function.
     -fno-builtin         # avoid emit unexpected calls
diff --git a/libc/startup/linux/do_start.cpp b/libc/startup/linux/do_start.cpp
index a67bf188b1ae3..6e2017ae1f46f 100644
--- a/libc/startup/linux/do_start.cpp
+++ b/libc/startup/linux/do_start.cpp
@@ -7,8 +7,12 @@
 //===----------------------------------------------------------------------===//
 #include "startup/linux/do_start.h"
 #include "config/linux/app.h"
+#include "hdr/linux_macros.h"
 #include "hdr/stdint_proxy.h"
-#include "include/llvm-libc-macros/link-macros.h"
+#include "hdr/types/Elf32_Dyn.h"
+#include "hdr/types/Elf32_Phdr.h"
+#include "hdr/types/Elf64_Dyn.h"
+#include "hdr/types/Elf64_Phdr.h"
 #include "src/__support/OSUtil/linux/auxv.h"
 #include "src/__support/OSUtil/syscall.h"
 #include "src/__support/macros/config.h"
@@ -17,8 +21,6 @@
 #include "src/stdlib/exit.h"
 #include "src/unistd/environ.h"
 
-#include <linux/auxvec.h>
-#include <linux/elf.h>
 #include <sys/mman.h>
 #include <sys/syscall.h>
 
@@ -37,7 +39,7 @@ extern uintptr_t __fini_array_end[];
 // This symbol is provided by the dynamic linker. It can be undefined depending
 // on how the program is loaded exactly.
 [[gnu::weak,
-  gnu::visibility("hidden")]] extern const Elf64_Dyn _DYNAMIC[]; // NOLINT
+  gnu::visibility("hidden")]] extern const ElfW(Dyn) _DYNAMIC[]; // NOLINT
 }
 
 namespace LIBC_NAMESPACE_DECL {

>From 5901a1529495f8640343d1f9798c0b8cf318f1d6 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Dec 2025 05:51:41 +0000
Subject: [PATCH 6/9] Fix include header name

---
 libc/startup/linux/do_start.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/startup/linux/do_start.cpp b/libc/startup/linux/do_start.cpp
index 6e2017ae1f46f..8a4c7af8a3eec 100644
--- a/libc/startup/linux/do_start.cpp
+++ b/libc/startup/linux/do_start.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 #include "startup/linux/do_start.h"
 #include "config/linux/app.h"
-#include "hdr/linux_macros.h"
+#include "hdr/link_macros.h"
 #include "hdr/stdint_proxy.h"
 #include "hdr/types/Elf32_Dyn.h"
 #include "hdr/types/Elf32_Phdr.h"

>From 2816f61a01348b582a86d4bd5898add6d0a5ba91 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Dec 2025 05:52:39 +0000
Subject: [PATCH 7/9] Include <elf.h>

---
 .../src/__support/OSUtil/linux/CMakeLists.txt | 19 +-----------------
 libc/src/__support/OSUtil/linux/vdso.cpp      | 20 ++-----------------
 libc/startup/linux/CMakeLists.txt             |  3 ++-
 libc/startup/linux/do_start.cpp               |  5 +----
 4 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt
index c73c38c3f6f4a..3489f631c6829 100644
--- a/libc/src/__support/OSUtil/linux/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt
@@ -73,26 +73,9 @@ add_object_library(
     libc.src.__support.OSUtil.linux.auxv
     libc.hdr.link_macros
     libc.hdr.sys_auxv_macros
-    libc.hdr.types.Elf32_Addr
-    libc.hdr.types.Elf32_Dyn
-    libc.hdr.types.Elf32_Ehdr
-    libc.hdr.types.Elf32_Phdr
-    libc.hdr.types.Elf32_Shdr
-    libc.hdr.types.Elf32_Sym
-    libc.hdr.types.Elf32_Verdaux
-    libc.hdr.types.Elf32_Verdef
-    libc.hdr.types.Elf32_Versym
-    libc.hdr.types.Elf64_Addr
-    libc.hdr.types.Elf64_Dyn
-    libc.hdr.types.Elf64_Ehdr
-    libc.hdr.types.Elf64_Phdr
-    libc.hdr.types.Elf64_Shdr
-    libc.hdr.types.Elf64_Sym
-    libc.hdr.types.Elf64_Verdaux
-    libc.hdr.types.Elf64_Verdef
-    libc.hdr.types.Elf64_Versym
     libc.hdr.types.clockid_t
     libc.hdr.types.struct_timespec
     libc.hdr.types.struct_timeval
     libc.hdr.types.time_t
+    libc.include.elf
 )
diff --git a/libc/src/__support/OSUtil/linux/vdso.cpp b/libc/src/__support/OSUtil/linux/vdso.cpp
index deff75f337bd7..6cd626a3997a7 100644
--- a/libc/src/__support/OSUtil/linux/vdso.cpp
+++ b/libc/src/__support/OSUtil/linux/vdso.cpp
@@ -8,24 +8,6 @@
 #include "src/__support/OSUtil/linux/vdso.h"
 #include "hdr/link_macros.h"
 #include "hdr/sys_auxv_macros.h"
-#include "hdr/types/Elf32_Addr.h"
-#include "hdr/types/Elf32_Dyn.h"
-#include "hdr/types/Elf32_Ehdr.h"
-#include "hdr/types/Elf32_Phdr.h"
-#include "hdr/types/Elf32_Shdr.h"
-#include "hdr/types/Elf32_Sym.h"
-#include "hdr/types/Elf32_Verdaux.h"
-#include "hdr/types/Elf32_Verdef.h"
-#include "hdr/types/Elf32_Versym.h"
-#include "hdr/types/Elf64_Addr.h"
-#include "hdr/types/Elf64_Dyn.h"
-#include "hdr/types/Elf64_Ehdr.h"
-#include "hdr/types/Elf64_Phdr.h"
-#include "hdr/types/Elf64_Shdr.h"
-#include "hdr/types/Elf64_Sym.h"
-#include "hdr/types/Elf64_Verdaux.h"
-#include "hdr/types/Elf64_Verdef.h"
-#include "hdr/types/Elf64_Versym.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/CPP/string_view.h"
@@ -33,6 +15,8 @@
 #include "src/__support/threads/callonce.h"
 #include "src/__support/threads/linux/futex_word.h"
 
+#include <elf.h>
+
 // TODO: This is a temporary workaround to avoid including elf.h
 // Include our own headers for ElfW and friends once we have them.
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 60deb4c8b1942..802bc7c17286b 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -96,12 +96,13 @@ add_object_library(
     do_start.h
   DEPENDS
     libc.config.app_h
+    libc.hdr.link_macros
     libc.hdr.stdint_proxy
     libc.hdr.types.Elf32_Phdr
     libc.hdr.types.Elf64_Phdr
     libc.hdr.types.Elf32_Dyn
     libc.hdr.types.Elf64_Dyn
-    libc.include.llvm-libc-macros.link_macros
+    libc.include.elf
     libc.include.sys_mman
     libc.include.sys_syscall
     libc.src.__support.OSUtil.linux.auxv
diff --git a/libc/startup/linux/do_start.cpp b/libc/startup/linux/do_start.cpp
index 8a4c7af8a3eec..b61c47457eb5e 100644
--- a/libc/startup/linux/do_start.cpp
+++ b/libc/startup/linux/do_start.cpp
@@ -9,10 +9,6 @@
 #include "config/linux/app.h"
 #include "hdr/link_macros.h"
 #include "hdr/stdint_proxy.h"
-#include "hdr/types/Elf32_Dyn.h"
-#include "hdr/types/Elf32_Phdr.h"
-#include "hdr/types/Elf64_Dyn.h"
-#include "hdr/types/Elf64_Phdr.h"
 #include "src/__support/OSUtil/linux/auxv.h"
 #include "src/__support/OSUtil/syscall.h"
 #include "src/__support/macros/config.h"
@@ -21,6 +17,7 @@
 #include "src/stdlib/exit.h"
 #include "src/unistd/environ.h"
 
+#include <elf.h>
 #include <sys/mman.h>
 #include <sys/syscall.h>
 

>From fc525002dc95606f050f069581454ef57a0080e0 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Dec 2025 06:06:46 +0000
Subject: [PATCH 8/9] Add missing dependencies

---
 libc/include/CMakeLists.txt | 12 ++++++++++++
 libc/include/elf.yaml       | 28 ++++++++++++++--------------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 2bb14802c2c0c..1bc9c2ca1a51d 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -478,13 +478,19 @@ add_header_macro(
   DEPENDS
     .llvm-libc-macros.elf_macros
     .llvm-libc-types.Elf32_Addr
+    .llvm-libc-types.Elf32_Chdr
+    .llvm-libc-types.Elf32_Dyn
     .llvm-libc-types.Elf32_Ehdr
     .llvm-libc-types.Elf32_Half
     .llvm-libc-types.Elf32_Lword
     .llvm-libc-types.Elf32_Nhdr
     .llvm-libc-types.Elf32_Off
     .llvm-libc-types.Elf32_Phdr
+    .llvm-libc-types.Elf32_Rel
+    .llvm-libc-types.Elf32_Rela
+    .llvm-libc-types.Elf32_Shdr
     .llvm-libc-types.Elf32_Sword
+    .llvm-libc-types.Elf32_Sym
     .llvm-libc-types.Elf32_Verdaux
     .llvm-libc-types.Elf32_Verdef
     .llvm-libc-types.Elf32_Vernaux
@@ -492,14 +498,20 @@ add_header_macro(
     .llvm-libc-types.Elf32_Versym
     .llvm-libc-types.Elf32_Word
     .llvm-libc-types.Elf64_Addr
+    .llvm-libc-types.Elf64_Chdr
+    .llvm-libc-types.Elf64_Dyn
     .llvm-libc-types.Elf64_Ehdr
     .llvm-libc-types.Elf64_Half
     .llvm-libc-types.Elf64_Lword
     .llvm-libc-types.Elf64_Nhdr
     .llvm-libc-types.Elf64_Off
     .llvm-libc-types.Elf64_Phdr
+    .llvm-libc-types.Elf64_Rel
+    .llvm-libc-types.Elf64_Rela
+    .llvm-libc-types.Elf64_Shdr
     .llvm-libc-types.Elf64_Sword
     .llvm-libc-types.Elf64_Sxword
+    .llvm-libc-types.Elf64_Sym
     .llvm-libc-types.Elf64_Verdaux
     .llvm-libc-types.Elf64_Verdef
     .llvm-libc-types.Elf64_Vernaux
diff --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index a3366a708b24c..0bb12910c67b5 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -421,47 +421,47 @@ macros:
     macro_value: '0xff01'
 types:
   - type_name: Elf32_Addr
-  - type_name: Elf32_Half
-  - type_name: Elf32_Off
-  - type_name: Elf32_Sword
-  - type_name: Elf32_Word
-  - type_name: Elf32_Lword
   - type_name: Elf32_Chdr
   - type_name: Elf32_Dyn
   - type_name: Elf32_Ehdr
-  - type_name: Elf32_Phdr
+  - type_name: Elf32_Half
+  - type_name: Elf32_Lword
   - type_name: Elf32_Nhdr
+  - type_name: Elf32_Off
+  - type_name: Elf32_Phdr
   - type_name: Elf32_Rel
   - type_name: Elf32_Rela
   - type_name: Elf32_Shdr
+  - type_name: Elf32_Sword
   - type_name: Elf32_Sym
   - type_name: Elf32_Verdaux
   - type_name: Elf32_Verdef
   - type_name: Elf32_Vernaux
   - type_name: Elf32_Verneed
   - type_name: Elf32_Versym
+  - type_name: Elf32_Word
   - type_name: Elf64_Addr
-  - type_name: Elf64_Half
-  - type_name: Elf64_Off
-  - type_name: Elf64_Sword
-  - type_name: Elf64_Sxword
-  - type_name: Elf64_Word
-  - type_name: Elf64_Lword
-  - type_name: Elf64_Xword
   - type_name: Elf64_Chdr
   - type_name: Elf64_Dyn
   - type_name: Elf64_Ehdr
-  - type_name: Elf64_Phdr
+  - type_name: Elf64_Half
+  - type_name: Elf64_Lword
   - type_name: Elf64_Nhdr
+  - type_name: Elf64_Off
+  - type_name: Elf64_Phdr
   - type_name: Elf64_Rel
   - type_name: Elf64_Rela
   - type_name: Elf64_Shdr
+  - type_name: Elf64_Sword
+  - type_name: Elf64_Sxword
   - type_name: Elf64_Sym
   - type_name: Elf64_Verdaux
   - type_name: Elf64_Verdef
   - type_name: Elf64_Vernaux
   - type_name: Elf64_Verneed
   - type_name: Elf64_Versym
+  - type_name: Elf64_Word
+  - type_name: Elf64_Xword
 enums: []
 objects: []
 functions: []

>From af6e6c06a3c671056fb383a3692fb90c186aee41 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Dec 2025 06:35:28 +0000
Subject: [PATCH 9/9] Fix hdr name in CMake

---
 libc/include/llvm-libc-types/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 569d32c8937aa..3124fdc33fbc2 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -275,7 +275,7 @@ add_header(
 add_header(
   Elf32_Verdef
   HDR
-    Elf32_Verdaux.h
+    Elf32_Verdef.h
   DEPENDS
     .Elf32_Half
     .Elf32_Word
@@ -398,7 +398,7 @@ add_header(
 add_header(
   Elf64_Verdef
   HDR
-    Elf64_Verdaux.h
+    Elf64_Verdef.h
   DEPENDS
     .Elf64_Half
     .Elf64_Word



More information about the libc-commits mailing list