From 9ee857d9b0b2a025b2a93ee57452ba97816c88e2 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Tue, 12 Sep 2023 14:08:58 +0800 Subject: [PATCH 1/2] Add program property We introduce .note.gnu.property section to store infomations that linker or runtime system may use, and we define 4 program property classes to specifying the merge semantics, it's used for forward compatibility in linker implementations, allowing linker can correctly handle program property types even if they are not recognized. We don't define any program property within this PR, it would be separate PR like #417 --- riscv-elf.adoc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/riscv-elf.adoc b/riscv-elf.adoc index f2c8da5f..428c865b 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -1077,6 +1077,7 @@ The defined processor-specific section types are listed in <>. | .riscv.attributes | SHT_RISCV_ATTRIBUTES | none | .riscv.jvt | SHT_PROGBITS | SHF_ALLOC + SHF_EXECINSTR +| .note.gnu.property | SHT_NOTE | SHF_ALLOC |=== +++.riscv.attributes+++ names a section that contains RISC-V ELF attributes. @@ -1084,6 +1085,8 @@ The defined processor-specific section types are listed in <>. +++.riscv.jvt+++ is a linker-created section to store table jump target addresses. The minimum alignment of this section is 64 bytes. ++++.note.gnu.property+++ names a section that contains a program property note. + === Program Header Table The defined processor-specific segment types are listed in <>. @@ -1350,6 +1353,43 @@ value. After the merge, the resulting value will be the non-zero one. -- +=== Program Property + +Program property are used to record information about an object file/binary that +a linker or runtime loader needs to check compatibility. + +The program property is divided into different classes, each defining a range +of program property types and specifying the merge semantics. This is designed +for forward compatibility in linker implementations, allowing them to correctly +handle program property types even if they are not recognized. + +[[rv-prog-prop-classes]] +.RISC-V-specific program property classes +[cols="3,2,2,5"] +[width=100%] +|=== +| Name | Range | Data Type | Merge Semantic + +| UINT32_AND | 0xc0000000 ~ 0xc0007fff | 4-bytes | A bit is set if it is set in all inputs. +| UINT32_OR | 0xc0008000 ~ 0xc000ffff | 4-bytes | A bit is set if it is set in any inputs. +| UINT32_OR_AND | 0xc0010000 ~ 0xc0017fff | 4-bytes | A bit is set if it is set in any inputs and the property is present in all inputs. +|=== + +[[rv-prog-prop-class-constants]] +.Constants for RISC-V-specific program property class +[cols="3,2"] +[width=80%] +|=== +| Name | Value + +| GNU_PROPERTY_RISCV_UINT32_AND_LO | 0xc0000000 +| GNU_PROPERTY_RISCV_UINT32_AND_HI | 0xc0007fff +| GNU_PROPERTY_RISCV_UINT32_OR_LO | 0xc0008000 +| GNU_PROPERTY_RISCV_UINT32_OR_HI | 0xc000ffff +| GNU_PROPERTY_RISCV_UINT32_OR_AND_LO | 0xc0010000 +| GNU_PROPERTY_RISCV_UINT32_OR_AND_HI | 0xc0017fff +|=== + === Mapping Symbol The section can have a mixture of code and data or code with different ISAs. From 7c0334a52a7d852ffa66c3d6b83074d4bb9c160d Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Wed, 17 Jul 2024 15:22:34 +0800 Subject: [PATCH 2/2] Drop generic rules --- riscv-elf.adoc | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/riscv-elf.adoc b/riscv-elf.adoc index 428c865b..e1979a7b 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -1355,40 +1355,11 @@ value. After the merge, the resulting value will be the non-zero one. === Program Property -Program property are used to record information about an object file/binary that -a linker or runtime loader needs to check compatibility. +Program properties are used to record information about an object file or binary +that a linker or runtime loader needs to check for compatibility. -The program property is divided into different classes, each defining a range -of program property types and specifying the merge semantics. This is designed -for forward compatibility in linker implementations, allowing them to correctly -handle program property types even if they are not recognized. - -[[rv-prog-prop-classes]] -.RISC-V-specific program property classes -[cols="3,2,2,5"] -[width=100%] -|=== -| Name | Range | Data Type | Merge Semantic - -| UINT32_AND | 0xc0000000 ~ 0xc0007fff | 4-bytes | A bit is set if it is set in all inputs. -| UINT32_OR | 0xc0008000 ~ 0xc000ffff | 4-bytes | A bit is set if it is set in any inputs. -| UINT32_OR_AND | 0xc0010000 ~ 0xc0017fff | 4-bytes | A bit is set if it is set in any inputs and the property is present in all inputs. -|=== - -[[rv-prog-prop-class-constants]] -.Constants for RISC-V-specific program property class -[cols="3,2"] -[width=80%] -|=== -| Name | Value - -| GNU_PROPERTY_RISCV_UINT32_AND_LO | 0xc0000000 -| GNU_PROPERTY_RISCV_UINT32_AND_HI | 0xc0007fff -| GNU_PROPERTY_RISCV_UINT32_OR_LO | 0xc0008000 -| GNU_PROPERTY_RISCV_UINT32_OR_HI | 0xc000ffff -| GNU_PROPERTY_RISCV_UINT32_OR_AND_LO | 0xc0010000 -| GNU_PROPERTY_RISCV_UINT32_OR_AND_HI | 0xc0017fff -|=== +The linker should ignore and discard unknown bits in program properties, and +issue warnings or errors. === Mapping Symbol