WIP MachO binutils port assisted by AI I may consider upstreaming this in the future.
0

Configure Feed

Select the types of activity you want to include in your feed.

RISC-V: Add GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED

This patch adds two new GNU properties for RISC-V:
GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED.

We only add readelf and define the properties in this patch.

Ref: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/417

authored by

Kito Cheng and committed by
Nelson Chu
(Jun 24, 2025, 6:14 PM +0800) 4ad5217c 51a39a59

+101
+39
binutils/readelf.c
··· 21288 21288 } 21289 21289 21290 21290 static void 21291 + decode_riscv_feature_1_and (unsigned int bitmask) 21292 + { 21293 + while (bitmask) 21294 + { 21295 + unsigned int bit = bitmask & (- bitmask); 21296 + 21297 + bitmask &= ~ bit; 21298 + switch (bit) 21299 + { 21300 + case GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED: 21301 + printf ("CFI_LP_UNLABELED"); 21302 + break; 21303 + 21304 + case GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS: 21305 + printf ("CFI_SS"); 21306 + break; 21307 + 21308 + default: 21309 + printf (_("<unknown: %x>"), bit); 21310 + break; 21311 + } 21312 + if (bitmask) 21313 + printf (", "); 21314 + } 21315 + } 21316 + 21317 + static void 21291 21318 decode_1_needed (unsigned int bitmask) 21292 21319 { 21293 21320 while (bitmask) ··· 21474 21501 printf (_("<corrupt length: %#x> "), datasz); 21475 21502 else 21476 21503 decode_aarch64_feature_1_and (byte_get (ptr, 4)); 21504 + goto next; 21505 + } 21506 + } 21507 + else if (filedata->file_header.e_machine == EM_RISCV) 21508 + { 21509 + if (type == GNU_PROPERTY_RISCV_FEATURE_1_AND) 21510 + { 21511 + printf ("RISC-V AND feature: "); 21512 + if (datasz != 4) 21513 + printf (_("<corrupt length: %#x> "), datasz); 21514 + else 21515 + decode_riscv_feature_1_and (byte_get (ptr, 4)); 21477 21516 goto next; 21478 21517 } 21479 21518 }
+5
include/elf/common.h
··· 1041 1041 #define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1) 1042 1042 #define GNU_PROPERTY_AARCH64_FEATURE_1_GCS (1U << 2) 1043 1043 1044 + /* RISC-V specific GNU PROPERTY. */ 1045 + #define GNU_PROPERTY_RISCV_FEATURE_1_AND 0xc0000000 1046 + #define GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED (1U << 0) 1047 + #define GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS (1U << 1) 1048 + 1044 1049 /* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */ 1045 1050 #define GNU_ABI_TAG_LINUX 0 1046 1051 #define GNU_ABI_TAG_HURD 1
+8
binutils/testsuite/binutils-all/riscv/property-cfi-lp-unlabeled.d
··· 1 + #as: -defsym __property_zicfilp_unlabeled__=1 -march=rv64i -mabi=lp64 2 + #readelf: -n 3 + #source: property.s 4 + 5 + Displaying notes found in: .note.gnu.property 6 + [ ]+Owner[ ]+Data size[ ]+Description 7 + [ ]+GNU[ ]+0x00000010[ ]+NT_GNU_PROPERTY_TYPE_0 8 + [ ]+Properties: RISC-V AND feature: CFI_LP_UNLABELED
+8
binutils/testsuite/binutils-all/riscv/property-cfi-ss.d
··· 1 + #as: -defsym __property_zicfiss__=1 -march=rv64i -mabi=lp64 2 + #readelf: -n 3 + #source: property.s 4 + 5 + Displaying notes found in: .note.gnu.property 6 + [ ]+Owner[ ]+Data size[ ]+Description 7 + [ ]+GNU[ ]+0x00000010[ ]+NT_GNU_PROPERTY_TYPE_0 8 + [ ]+Properties: RISC-V AND feature: CFI_SS
+41
binutils/testsuite/binutils-all/riscv/property.s
··· 1 + .text 2 + .globl _start 3 + .type _start,@function 4 + _start: 5 + ret 6 + 7 + .ifdef __property_zicfilp_unlabeled__ 8 + .section ".note.gnu.property", "a" 9 + .p2align 3 10 + .long 1f - 0f /* name length */ 11 + .long 5f - 2f /* data length */ 12 + .long 5 /* note type */ 13 + 0: .asciz "GNU" /* vendor name */ 14 + 1: 15 + .p2align 3 16 + 2: .long 0xc0000000 /* pr_type. */ 17 + .long 4f - 3f /* pr_datasz. */ 18 + 3: 19 + .long 0x1 /* GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED. */ 20 + 4: 21 + .p2align 3 22 + 5: 23 + .endif 24 + 25 + .ifdef __property_zicfiss__ 26 + .section ".note.gnu.property", "a" 27 + .p2align 3 28 + .long 1f - 0f /* name length */ 29 + .long 5f - 2f /* data length */ 30 + .long 5 /* note type */ 31 + 0: .asciz "GNU" /* vendor name */ 32 + 1: 33 + .p2align 3 34 + 2: .long 0xc0000000 /* pr_type. */ 35 + .long 4f - 3f /* pr_datasz. */ 36 + 3: 37 + .long 0x2 /* GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS. */ 38 + 4: 39 + .p2align 3 40 + 5: 41 + .endif