[libc-commits] [libc] dc55e20 - [libc] Add Elf32_Xword type (#177915)

via libc-commits libc-commits at lists.llvm.org
Mon Jan 26 14:48:39 PST 2026


Author: Jakob Koschel
Date: 2026-01-26T14:48:35-08:00
New Revision: dc55e20483ac1e5d28bec002bcd9f185da24e307

URL: https://github.com/llvm/llvm-project/commit/dc55e20483ac1e5d28bec002bcd9f185da24e307
DIFF: https://github.com/llvm/llvm-project/commit/dc55e20483ac1e5d28bec002bcd9f185da24e307.diff

LOG: [libc] Add Elf32_Xword type (#177915)

In a recent PR (https://github.com/llvm/llvm-project/pull/174772), we
introduced GnuPropertySection using ElfW(Xword). Since we are currently
missing Elf32_Xword, this is failing on 32bit architectures.

This commit adds the missing Elf32_Xword type that should always hold
64bit even on 32bit architectures.

Added: 
    libc/hdr/types/Elf32_Xword.h
    libc/include/llvm-libc-types/Elf32_Xword.h

Modified: 
    libc/hdr/CMakeLists.txt
    libc/hdr/types/CMakeLists.txt
    libc/include/CMakeLists.txt
    libc/include/elf.yaml
    libc/include/llvm-libc-macros/link-macros.h
    libc/include/llvm-libc-types/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt
index 1d78454ba9ffb..6362c10788b2b 100644
--- a/libc/hdr/CMakeLists.txt
+++ b/libc/hdr/CMakeLists.txt
@@ -294,6 +294,7 @@ add_gen_header(
     libc.include.llvm-libc-types.Elf32_Verneed
     libc.include.llvm-libc-types.Elf32_Versym
     libc.include.llvm-libc-types.Elf32_Word
+    libc.include.llvm-libc-types.Elf32_Xword
     libc.include.llvm-libc-types.Elf64_Addr
     libc.include.llvm-libc-types.Elf64_Chdr
     libc.include.llvm-libc-types.Elf64_Dyn

diff  --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 362feefa67783..3385fe81fe223 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -648,6 +648,14 @@ add_proxy_header_library(
     libc.include.llvm-libc-types.Elf32_Word
 )
 
+add_proxy_header_library(
+  Elf32_Xword
+  HDRS
+  Elf32_Xword.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-types.Elf32_Xword
+)
+
 add_proxy_header_library(
   Elf64_Addr
   HDRS

diff  --git a/libc/hdr/types/Elf32_Xword.h b/libc/hdr/types/Elf32_Xword.h
new file mode 100644
index 0000000000000..4eeea1c772559
--- /dev/null
+++ b/libc/hdr/types/Elf32_Xword.h
@@ -0,0 +1,22 @@
+//===-- Proxy for Elf32_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_ELF32_XWORD_H
+#define LLVM_LIBC_HDR_TYPES_ELF32_XWORD_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/Elf32_Xword.h"
+
+#else // Overlay mode
+
+#include <elf.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_ELF32_XWORD_H

diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 1bc9c2ca1a51d..c6254aafe3849 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -497,6 +497,7 @@ add_header_macro(
     .llvm-libc-types.Elf32_Verneed
     .llvm-libc-types.Elf32_Versym
     .llvm-libc-types.Elf32_Word
+    .llvm-libc-types.Elf32_Xword
     .llvm-libc-types.Elf64_Addr
     .llvm-libc-types.Elf64_Chdr
     .llvm-libc-types.Elf64_Dyn
@@ -800,7 +801,7 @@ add_header_macro(
   ../libc/include/wctype.yaml
   wctype.h
   DEPENDS
-    .llvm_libc_common_h    
+    .llvm_libc_common_h
     .llvm-libc-types.wint_t
 )
 

diff  --git a/libc/include/elf.yaml b/libc/include/elf.yaml
index fc0a8321666d0..6cb9122e013a9 100644
--- a/libc/include/elf.yaml
+++ b/libc/include/elf.yaml
@@ -461,6 +461,7 @@ types:
   - type_name: Elf32_Verneed
   - type_name: Elf32_Versym
   - type_name: Elf32_Word
+  - type_name: Elf32_Xword
   - type_name: Elf64_Addr
   - type_name: Elf64_Chdr
   - type_name: Elf64_Dyn

diff  --git a/libc/include/llvm-libc-macros/link-macros.h b/libc/include/llvm-libc-macros/link-macros.h
index 1876a6dc848d1..7430e5268b104 100644
--- a/libc/include/llvm-libc-macros/link-macros.h
+++ b/libc/include/llvm-libc-macros/link-macros.h
@@ -24,6 +24,7 @@
 #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/Elf32_Xword.h"
 #include "../llvm-libc-types/Elf64_Addr.h"
 #include "../llvm-libc-types/Elf64_Chdr.h"
 #include "../llvm-libc-types/Elf64_Dyn.h"

diff  --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 3124fdc33fbc2..dc36dfeadba57 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -194,6 +194,7 @@ add_header(Elf32_Lword HDR Elf32_Lword.h DEPENDS libc.include.llvm-libc-macros.s
 add_header(Elf32_Off HDR Elf32_Off.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf32_Sword HDR Elf32_Sword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(Elf32_Word HDR Elf32_Word.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
+add_header(Elf32_Xword HDR Elf32_Xword.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(
   Elf32_Chdr
   HDR

diff  --git a/libc/include/llvm-libc-types/Elf32_Xword.h b/libc/include/llvm-libc-types/Elf32_Xword.h
new file mode 100644
index 0000000000000..9a4898043b041
--- /dev/null
+++ b/libc/include/llvm-libc-types/Elf32_Xword.h
@@ -0,0 +1,16 @@
+//===-- Definition of Elf32_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_ELF32_XWORD_H
+#define LLVM_LIBC_TYPES_ELF32_XWORD_H
+
+#include "../llvm-libc-macros/stdint-macros.h"
+
+typedef uint64_t Elf32_Xword;
+
+#endif // LLVM_LIBC_TYPES_ELF32_XWORD_H


        


More information about the libc-commits mailing list