diff options
author | Kito Cheng <kito.cheng@sifive.com> | 2021-06-29 14:36:35 +0800 |
---|---|---|
committer | Nelson Chu <nelson.chu@sifive.com> | 2021-07-06 11:34:36 +0800 |
commit | fbc95f1e11facf233e89a9c2b4dde06b9aaf4b86 (patch) | |
tree | 810aa9b4b50933cd6e9e7f844d15886db695fd2a /binutils/readelf.c | |
parent | 07b2745f850232e1c2fdafb0f65ea88e6127218b (diff) | |
download | gdb-fbc95f1e11facf233e89a9c2b4dde06b9aaf4b86.zip gdb-fbc95f1e11facf233e89a9c2b4dde06b9aaf4b86.tar.gz gdb-fbc95f1e11facf233e89a9c2b4dde06b9aaf4b86.tar.bz2 |
RISC-V: Add PT_RISCV_ATTRIBUTES and add it to PHDR.
We added PT_RISCV_ATTRIBUTES to program header to make
.riscv.attribute easier to find in dynamic loader or kernel.
Ref:
https://github.com/riscv/riscv-elf-psabi-doc/pull/71
ChangeLog:
bfd/
* elfnn-riscv.c(RISCV_ATTRIBUTES_SECTION_NAME): New.
(riscv_elf_additional_program_headers): Ditto.
(riscv_elf_modify_segment_map): Ditto.
(elf_backend_additional_program_headers): Ditto.
(elf_backend_modify_segment_map): Ditto.
(elf_backend_obj_attrs_section): Use RISCV_ATTRIBUTES_SECTION_NAME
rather than string literal.
binutils/
* readelf.c(get_riscv_segment_type): New.
(get_segment_type): Handle EM_RISCV.
include/
* elf/riscv.h (PT_RISCV_ATTRIBUTES): New.
* testsuite/ld-elf/orphan-region.ld: Discard .riscv.attributes
section for simplify testcase.
* testsuite/ld-riscv-elf/attr-phdr.d: New.
* testsuite/ld-riscv-elf/attr-phdr.s: Ditto.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Add attr-phdr to
testcase.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r-- | binutils/readelf.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c index a6073f7..2215339 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -4095,6 +4095,16 @@ get_tic6x_segment_type (unsigned long type) } static const char * +get_riscv_segment_type (unsigned long type) +{ + switch (type) + { + case PT_RISCV_ATTRIBUTES: return "RISCV_ATTRIBUTES"; + default: return NULL; + } +} + +static const char * get_hpux_segment_type (unsigned long type, unsigned e_machine) { if (e_machine == EM_PARISC) @@ -4203,6 +4213,9 @@ get_segment_type (Filedata * filedata, unsigned long p_type) case EM_S390_OLD: result = get_s390_segment_type (p_type); break; + case EM_RISCV: + result = get_riscv_segment_type (p_type); + break; default: result = NULL; break; |