From fc23a5cf91287e1a7931187f7160ab71aaa27f26 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 6 Jun 2023 22:05:39 -0700 Subject: [PATCH 1/2] Remove PT_RISCV_ATTRIBUTES #71 added a PT_RISCV_ATTRIBUTES segment to contain the SHT_RISCV_ATTRIBUTES section. The SHT_RISCV_ATTRIBUTES section does not have the SHF_ALLOC flag and is therefore not in a PT_LOAD segment. Dynamic loaders cannot assume the PT_RISCV_ATTRIBUTES part is present (it may happen to be mapped due to page alignment, but there is no guarantee). To the best of my knowledge, PT_RISCV_ATTRIBUTES is the only open-source usage of a segment that contains a non-SHF_ALLOC section. I think the existence of PT_RISCV_ATTRIBUTES just complicates analysis tools and binary manipulation tools like strip. E.g. if the SHT_RISCV_ATTRIBUTES section is removed, what should we do with PT_RISCV_ATTRIBUTES? I think we should remove PT_RISCV_ATTRIBUTES, but ensure that the program header type is not reused by a future program header type. --- riscv-elf.adoc | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/riscv-elf.adoc b/riscv-elf.adoc index d5e560a7..9e0851cb 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -1092,22 +1092,6 @@ 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. -=== Program Header Table - -The defined processor-specific segment types are listed in <>. - -[[rv-seg-type]] -.RISC-V-specific segment types -[cols="3,2,3"] -[width=80%] -|=== -| Name | Value | Meaning - -| PT_RISCV_ATTRIBUTES | 0x70000003 | RISC-V ELF attribute section. -|=== - -`PT_RISCV_ATTRIBUTES` describes the location of RISC-V ELF attribute section. - === Note Sections There are no RISC-V specific definitions relating to ELF note sections. From 5ed0ec88a4a62542a7a72871297b07b4bbf2afc4 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 12 Apr 2024 09:38:54 -0700 Subject: [PATCH 2/2] Deprecate PT_RISCV_ATTRIBUTES --- riscv-elf.adoc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/riscv-elf.adoc b/riscv-elf.adoc index 9e0851cb..6ce6d462 100644 --- a/riscv-elf.adoc +++ b/riscv-elf.adoc @@ -1092,6 +1092,26 @@ 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. +=== Program Header Table + +The defined processor-specific segment types are listed in <>. + +[[rv-seg-type]] +.RISC-V-specific segment types +[cols="3,2,3"] +[width=80%] +|=== +| Name | Value | Meaning + +| PT_RISCV_ATTRIBUTES | 0x70000003 | RISC-V ELF attribute section. +|=== + +`PT_RISCV_ATTRIBUTES` describes the location of RISC-V ELF attribute section. + +WARNING: `PT_RISCV_ATTRIBUTES` is deprecated. The build attributes section does +not contain the `SHF_ALLOC` flag. Dynamic loaders cannot assume that the region +described by `PT_RISCV_ATTRIBUTES` is present. + === Note Sections There are no RISC-V specific definitions relating to ELF note sections.