diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake index 0704ae1c79e1..dc2bb843fdcb 100644 --- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake +++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake @@ -81,7 +81,7 @@ function(add_gen_header target_name) ${ARGN} ) get_fq_target_name(${target_name} fq_target_name) - if(NOT LLVM_LIBC_FULL_BUILD) + if(NOT LLVM_LIBC_FULL_BUILD AND NOT ADD_GEN_HDR_PROXY) add_library(${fq_target_name} INTERFACE) return() endif() diff --git a/libc/config/baremetal/aarch64/headers.txt b/libc/config/baremetal/aarch64/headers.txt index 5666ef7e0012..31cc04d84910 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 1f64afebdaaa..a259c3a4d834 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 1f64afebdaaa..a259c3a4d834 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/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt index f3f01c1ed0e3..fec38b3caca4 100644 --- a/libc/hdr/CMakeLists.txt +++ b/libc/hdr/CMakeLists.txt @@ -1,3 +1,8 @@ +set(LIBC_INCLUDE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LIBC_INCLUDE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +include(LLVMLibCHeaderRules) + function(add_proxy_header_library target_name) cmake_parse_arguments( "ADD_PROXY_HEADER" @@ -261,5 +266,16 @@ add_proxy_header_library( libc.include.stdint ) +add_gen_header( + elf_proxy + YAML_FILE + ../libc/include/elf.yaml + GEN_HDR + elf_proxy.h + DEPENDS + libc.include.llvm_libc_common_h + PROXY +) + add_subdirectory(types) add_subdirectory(func) diff --git a/libc/hdr/elf_macros.h b/libc/hdr/elf_macros.h new file mode 100644 index 000000000000..804da4d88c66 --- /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 + +#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 433c47b17476..362feefa6778 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 000000000000..e9427572e2a2 --- /dev/null +++ b/libc/hdr/types/Elf32_Addr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..ad5115623b18 --- /dev/null +++ b/libc/hdr/types/Elf32_Chdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..4aa22e1bfaa5 --- /dev/null +++ b/libc/hdr/types/Elf32_Dyn.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..e0997130c4f8 --- /dev/null +++ b/libc/hdr/types/Elf32_Ehdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..25acb3a14a7b --- /dev/null +++ b/libc/hdr/types/Elf32_Half.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..c348e8f3035a --- /dev/null +++ b/libc/hdr/types/Elf32_Lword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..18cf14d7c253 --- /dev/null +++ b/libc/hdr/types/Elf32_Nhdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..f584f9fcf52f --- /dev/null +++ b/libc/hdr/types/Elf32_Off.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..ba9569fd9799 --- /dev/null +++ b/libc/hdr/types/Elf32_Phdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..5221dcf1c5be --- /dev/null +++ b/libc/hdr/types/Elf32_Rel.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..a933ec2ccf61 --- /dev/null +++ b/libc/hdr/types/Elf32_Rela.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..fc0f3fec63c6 --- /dev/null +++ b/libc/hdr/types/Elf32_Shdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..d69b95cffa0c --- /dev/null +++ b/libc/hdr/types/Elf32_Sword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..c405975e15a3 --- /dev/null +++ b/libc/hdr/types/Elf32_Sym.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..fee95368b84a --- /dev/null +++ b/libc/hdr/types/Elf32_Verdaux.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..894357848d79 --- /dev/null +++ b/libc/hdr/types/Elf32_Verdef.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..47dd6140a74c --- /dev/null +++ b/libc/hdr/types/Elf32_Vernaux.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..37260dede2ec --- /dev/null +++ b/libc/hdr/types/Elf32_Verneed.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..bacf492f6916 --- /dev/null +++ b/libc/hdr/types/Elf32_Versym.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..a1fde15dbf95 --- /dev/null +++ b/libc/hdr/types/Elf32_Word.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..28454c5c52ac --- /dev/null +++ b/libc/hdr/types/Elf64_Addr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..2252740a4a27 --- /dev/null +++ b/libc/hdr/types/Elf64_Chdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..146060645c1b --- /dev/null +++ b/libc/hdr/types/Elf64_Dyn.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..15228425a898 --- /dev/null +++ b/libc/hdr/types/Elf64_Ehdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..391d94437933 --- /dev/null +++ b/libc/hdr/types/Elf64_Half.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..fc55527e7ddd --- /dev/null +++ b/libc/hdr/types/Elf64_Lword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..6329658fb40c --- /dev/null +++ b/libc/hdr/types/Elf64_Nhdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..331d76d040ab --- /dev/null +++ b/libc/hdr/types/Elf64_Off.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..9d7ccc09d44d --- /dev/null +++ b/libc/hdr/types/Elf64_Phdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..aba220f9d3f3 --- /dev/null +++ b/libc/hdr/types/Elf64_Rel.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..b55e501456f1 --- /dev/null +++ b/libc/hdr/types/Elf64_Rela.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..a96d17614310 --- /dev/null +++ b/libc/hdr/types/Elf64_Shdr.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..a9e6376e745a --- /dev/null +++ b/libc/hdr/types/Elf64_Sword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..08cdff0059e9 --- /dev/null +++ b/libc/hdr/types/Elf64_Sxword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..7b8fdb84ae69 --- /dev/null +++ b/libc/hdr/types/Elf64_Sym.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..4afc99fe2157 --- /dev/null +++ b/libc/hdr/types/Elf64_Verdaux.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..caaf95db1d0c --- /dev/null +++ b/libc/hdr/types/Elf64_Verdef.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..d692830f1451 --- /dev/null +++ b/libc/hdr/types/Elf64_Vernaux.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..89c803770700 --- /dev/null +++ b/libc/hdr/types/Elf64_Verneed.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..9b7a61c52025 --- /dev/null +++ b/libc/hdr/types/Elf64_Versym.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..4c161e91eeca --- /dev/null +++ b/libc/hdr/types/Elf64_Word.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 000000000000..e275bcbedf25 --- /dev/null +++ b/libc/hdr/types/Elf64_Xword.h @@ -0,0 +1,22 @@ +//===-- 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 + +#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 96c3a88f3fcc..1bc9c2ca1a51 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -477,6 +477,48 @@ add_header_macro( elf.h 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 + .llvm-libc-types.Elf32_Verneed + .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 + .llvm-libc-types.Elf64_Verneed + .llvm-libc-types.Elf64_Versym + .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 f78ae82c7785..a97d407d835b 100644 --- a/libc/include/elf.yaml +++ b/libc/include/elf.yaml @@ -1,9 +1,481 @@ header: elf.h header_template: elf.h.def standards: - - Linux -macros: [] -types: [] + - svid +macros: + # ELF Header + - macro_name: EI_NIDENT + macro_value: 16 + - 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: ELFOSABI_LINUX + macro_value: 3 + - 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: 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 + 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 + 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' + # 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: DT_VERSYM + macro_value: '0x6ffffff0' + - macro_name: DT_RELACOUNT + macro_value: '0x6ffffff9' + - macro_name: DT_RELCOUNT + macro_value: '0x6ffffffa' + - macro_name: DT_VERDEF + macro_value: '0x6ffffffc' + - macro_name: DT_VERDEFNUM + macro_value: '0x6ffffffd' + - macro_name: DT_VERNEED + macro_value: '0x6ffffffe' + - macro_name: DT_VERNEEDNUM + macro_value: '0x6fffffff' + - 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 + - macro_name: NT_PRFPREG + macro_value: 2 + - macro_name: NT_PRPSINFO + macro_value: 3 + - macro_name: NT_TASKSTRUCT + macro_value: 4 + - macro_name: NT_PLATFORM + macro_value: 5 + - macro_name: NT_AUXV + macro_value: 6 + # 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_Chdr + - type_name: Elf32_Dyn + - type_name: Elf32_Ehdr + - 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_Chdr + - type_name: Elf64_Dyn + - type_name: Elf64_Ehdr + - 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: [] diff --git a/libc/include/link.h.def b/libc/include/link.h.def new file mode 100644 index 000000000000..b9c83e87751b --- /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 + +%%public_api() + +#endif // LLVM_LIBC_LINK_H diff --git a/libc/include/link.yaml b/libc/include/link.yaml index 7e303a4436d8..b917bc0a61ae 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 fa4442abf0f5..6857b6681bfa 100644 --- a/libc/include/llvm-libc-macros/elf-macros.h +++ b/libc/include/llvm-libc-macros/elf-macros.h @@ -9,10 +9,27 @@ #ifndef LLVM_LIBC_MACROS_ELF_MACROS_H #define LLVM_LIBC_MACROS_ELF_MACROS_H -#if __has_include() -#include -#else -#error "cannot use without proper system headers." -#endif +// 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 89e7bb50aa55..1876a6dc848d 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 fcd0e1245a4a..3124fdc33fbc 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -187,6 +187,246 @@ 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_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 + Elf32_Ehdr.h + DEPENDS + .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( + 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( + Elf32_Verdaux + HDR + Elf32_Verdaux.h + DEPENDS + .Elf32_Word +) +add_header( + Elf32_Verdef + HDR + Elf32_Verdef.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) +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_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 + Elf64_Ehdr.h + DEPENDS + .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 +) +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 +) +add_header( + Elf64_Verdaux + HDR + Elf64_Verdaux.h + DEPENDS + .Elf64_Word +) +add_header( + Elf64_Verdef + HDR + Elf64_Verdef.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) add_header(EFI_CONFIGURATION_TABLE HDR EFI_CONFIGURATION_TABLE.h DEPENDS .EFI_GUID) 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 000000000000..16cca621fbd4 --- /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_Chdr.h b/libc/include/llvm-libc-types/Elf32_Chdr.h new file mode 100644 index 000000000000..dad95b9a6d79 --- /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 000000000000..0871bb0311fc --- /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 // 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 new file mode 100644 index 000000000000..01ae842829c4 --- /dev/null +++ b/libc/include/llvm-libc-types/Elf32_Ehdr.h @@ -0,0 +1,37 @@ +//===-- 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 "Elf32_Addr.h" +#include "Elf32_Half.h" +#include "Elf32_Off.h" +#include "Elf32_Word.h" + +// NOTE: This macro is also defined in Elf64_Ehdr.h. +#define EI_NIDENT 16 + +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 000000000000..b614b416d51a --- /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 000000000000..5d1e634a1b9b --- /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 000000000000..2deca0376fa1 --- /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_Nhdr; + +#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 000000000000..46c7118d95e7 --- /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 000000000000..1fcb6d0e1810 --- /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_Rel.h b/libc/include/llvm-libc-types/Elf32_Rel.h new file mode 100644 index 000000000000..a712add4bd21 --- /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 000000000000..a1eabcd703d8 --- /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 000000000000..179a2c7c3f4e --- /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_Sword.h b/libc/include/llvm-libc-types/Elf32_Sword.h new file mode 100644 index 000000000000..8adbba727afd --- /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_Sym.h b/libc/include/llvm-libc-types/Elf32_Sym.h new file mode 100644 index 000000000000..7363abc1792c --- /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/Elf32_Verdaux.h b/libc/include/llvm-libc-types/Elf32_Verdaux.h new file mode 100644 index 000000000000..6b0ab6d306ed --- /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 000000000000..9030eb38173d --- /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 000000000000..0268882f2d09 --- /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 000000000000..a76fc69caf7b --- /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 000000000000..e5930a1018eb --- /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/Elf32_Word.h b/libc/include/llvm-libc-types/Elf32_Word.h new file mode 100644 index 000000000000..7444a8b41ff4 --- /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 000000000000..a186c1b316f4 --- /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_Chdr.h b/libc/include/llvm-libc-types/Elf64_Chdr.h new file mode 100644 index 000000000000..7110f5b45d16 --- /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 000000000000..7efc793e2fa0 --- /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_Ehdr.h b/libc/include/llvm-libc-types/Elf64_Ehdr.h new file mode 100644 index 000000000000..3e49bbe5d847 --- /dev/null +++ b/libc/include/llvm-libc-types/Elf64_Ehdr.h @@ -0,0 +1,37 @@ +//===-- 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 "Elf64_Addr.h" +#include "Elf64_Half.h" +#include "Elf64_Off.h" +#include "Elf64_Word.h" + +// NOTE: This macro is also defined in Elf32_Ehdr.h. +#define EI_NIDENT 16 + +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 000000000000..2f0bfe88992d --- /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 000000000000..5435e1d8e5de --- /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 000000000000..7e42f0fc8988 --- /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_Nhdr; + +#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 000000000000..e33c47e65815 --- /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 000000000000..e5c96a56491d --- /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_Rel.h b/libc/include/llvm-libc-types/Elf64_Rel.h new file mode 100644 index 000000000000..48e670c8d14f --- /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 000000000000..945ecd228829 --- /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 000000000000..7ffd1e71a1f9 --- /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_Sword.h b/libc/include/llvm-libc-types/Elf64_Sword.h new file mode 100644 index 000000000000..dfadd3c7b4db --- /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 000000000000..6f66e0d8098a --- /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_Sym.h b/libc/include/llvm-libc-types/Elf64_Sym.h new file mode 100644 index 000000000000..367c72897fc6 --- /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 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 000000000000..bdfa5f66e0e9 --- /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 000000000000..9c1823f38762 --- /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 000000000000..f88eb1e20d91 --- /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 000000000000..2edfec59525b --- /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 000000000000..b3057386514e --- /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/include/llvm-libc-types/Elf64_Word.h b/libc/include/llvm-libc-types/Elf64_Word.h new file mode 100644 index 000000000000..0f001460e054 --- /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 000000000000..70438b612dbe --- /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 diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt index 0a6037757f5a..bb7bd3fdf3f6 100644 --- a/libc/src/__support/OSUtil/linux/CMakeLists.txt +++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt @@ -71,9 +71,11 @@ 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.types.clockid_t - libc.hdr.types.time_t + libc.hdr.elf_proxy libc.hdr.link_macros + libc.hdr.sys_auxv_macros + libc.hdr.types.clockid_t + libc.hdr.types.struct_timespec + libc.hdr.types.struct_timeval + libc.hdr.types.time_t ) diff --git a/libc/src/__support/OSUtil/linux/vdso.cpp b/libc/src/__support/OSUtil/linux/vdso.cpp index d6fd3f331259..1dac5bd5b5ff 100644 --- a/libc/src/__support/OSUtil/linux/vdso.cpp +++ b/libc/src/__support/OSUtil/linux/vdso.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// #include "src/__support/OSUtil/linux/vdso.h" +#include "hdr/elf_proxy.h" #include "hdr/link_macros.h" #include "hdr/sys_auxv_macros.h" #include "src/__support/CPP/array.h" @@ -14,7 +15,6 @@ #include "src/__support/OSUtil/linux/auxv.h" #include "src/__support/threads/callonce.h" #include "src/__support/threads/linux/futex_word.h" -#include // 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 +26,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(reinterpret_cast(this) + - vd_next); - } - Verdaux *aux() const { - return reinterpret_cast(reinterpret_cast(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 +38,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(reinterpret_cast(def) + + def->vd_next)) { // skip if this is a file-level version if (def->vd_flags & VER_FLG_BASE) continue; @@ -71,7 +49,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( + reinterpret_cast(def) + def->vd_aux); return strtab + aux->vda_name; } } @@ -96,8 +75,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 +134,8 @@ struct PhdrInfo { cpp::optional 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 +148,7 @@ struct PhdrInfo { versym = reinterpret_cast(vdso_addr + d->d_un.d_ptr); break; case DT_VERDEF: - verdef = reinterpret_cast(vdso_addr + d->d_un.d_ptr); + verdef = reinterpret_cast(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 df2c4b9ec508..27dafa716083 100644 --- a/libc/startup/linux/CMakeLists.txt +++ b/libc/startup/linux/CMakeLists.txt @@ -96,16 +96,17 @@ add_object_library( do_start.h DEPENDS libc.config.app_h + libc.hdr.elf_proxy + libc.hdr.link_macros libc.hdr.stdint_proxy 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 12493d8e66ef..aac9a0c10bf9 100644 --- a/libc/startup/linux/do_start.cpp +++ b/libc/startup/linux/do_start.cpp @@ -7,8 +7,9 @@ //===----------------------------------------------------------------------===// #include "startup/linux/do_start.h" #include "config/linux/app.h" +#include "hdr/elf_proxy.h" +#include "hdr/link_macros.h" #include "hdr/stdint_proxy.h" -#include "include/llvm-libc-macros/link-macros.h" #include "src/__support/OSUtil/linux/auxv.h" #include "src/__support/OSUtil/syscall.h" #include "src/__support/macros/config.h" @@ -17,8 +18,6 @@ #include "src/stdlib/exit.h" #include "src/unistd/environ.h" -#include -#include #include #include @@ -37,7 +36,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 {