[libc-commits] [libc] [libc][linux] add support to parse PT_GNU_PROPERTY (PR #174772)

Jakob Koschel via libc-commits libc-commits at lists.llvm.org
Wed Jan 14 05:58:29 PST 2026


================
@@ -0,0 +1,116 @@
+//===-- Implementation file of gnu_property_section -----------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+#include "startup/linux/gnu_property_section.h"
+
+#include "include/llvm-libc-macros/link-macros.h"
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/macros/config.h"
+#include "src/string/memory_utils/utils.h"
+
+#include <linux/elf.h>
+
+#ifdef LIBC_TARGET_ARCH_IS_X86_64
+
+// Property types used in GNU_PROPERTY_TYPE_0 notes
+// (currently only X86_FEATURE_1_AND required).
+#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
+
+// x86 processor feature bits (currently only SHSTK required).
+#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1)
+
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+
+bool GnuPropertySection::Parse(const ElfW(Phdr) * gnu_property_phdr,
----------------
jakos-sec wrote:

There is a comment on top of the GnuPropertySection (in the header):
```
// The layout of the .note.gnu.property section and the program property is
// described in "System V Application Binary Interface - Linux Extensions"
// (https://github.com/hjl-tools/linux-abi/wiki).
```

Do you think that's sufficient or should I expand there?

https://github.com/llvm/llvm-project/pull/174772


More information about the libc-commits mailing list