elf: add PT_RISCV_ATTRIBUTES program header

Attribute is ignored for now.

It is supposed to check ABI compatiblity and reject loading incompatible images.
Haiku currently do not use multiple ABIs for RISC-V so it is safe to ignore attributes.

PT_RISCV_ATTRIBUTES program header is produced by default in GCC 13 and Clang 17.

Change-Id: I4659e9bacbf34a2a0bc16b34c2aaa37232d700fa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6948
Reviewed-by: David Karoly <karolyd577@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
X512 2023-09-25 11:44:29 +09:00 committed by waddlesplash
parent abd18fecf0
commit f83058d1ed
4 changed files with 11 additions and 0 deletions

View File

@ -339,6 +339,7 @@ typedef struct {
#define PT_LOPROC 0x70000000
#define PT_ARM_UNWIND 0x70000001
#define PT_RISCV_ATTRIBUTES 0x70000003
#define PT_HIPROC 0x7fffffff
/* program header segment flags */

View File

@ -350,6 +350,7 @@ typedef struct {
#define PT_LOPROC 0x70000000
#define PT_ARM_UNWIND 0x70000001
#define PT_RISCV_ATTRIBUTES 0x70000003
#define PT_HIPROC 0x7fffffff
/* program header segment flags */

View File

@ -2279,6 +2279,9 @@ load_kernel_add_on(const char *path)
continue;
case PT_ARM_UNWIND:
continue;
case PT_RISCV_ATTRIBUTES:
// TODO: check ABI compatibility attributes
continue;
default:
dprintf("%s: unhandled pheader type %#" B_PRIx32 "\n", fileName,
programHeaders[i].p_type);

View File

@ -88,6 +88,9 @@ count_regions(const char* imagePath, char const* buff, int phnum, int phentsize)
case PT_ARM_UNWIND:
// will be handled in libgcc_s.so.1
break;
case PT_RISCV_ATTRIBUTES:
// TODO: check ABI compatibility attributes
break;
default:
FATAL("%s: Unhandled pheader type in count 0x%" B_PRIx32 "\n",
imagePath, pheaders->p_type);
@ -219,6 +222,9 @@ parse_program_headers(image_t* image, char* buff, int phnum, int phentsize)
case PT_ARM_UNWIND:
// will be handled in libgcc_s.so.1
break;
case PT_RISCV_ATTRIBUTES:
// TODO: check ABI compatibility attributes
break;
default:
FATAL("%s: Unhandled pheader type in parse 0x%" B_PRIx32 "\n",
image->path, pheader->p_type);