Skip to content

Commit

Permalink
elftoolchain: Add support for PT_COMPARTMENT and DT_C18NSTRTAB*
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdjhb committed Dec 11, 2024
1 parent 83ec9c0 commit 341a20c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contrib/elftoolchain/common/elfdefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ _ELF_DEFINE_DT(DT_SUNW_CAP, 0x60000010UL, \
"address of hardware capabilities section") \
_ELF_DEFINE_DT(DT_SUNW_ASLR, 0x60000023UL, \
"Address Space Layout Randomization flag") \
_ELF_DEFINE_DT(DT_C18NSTRTAB, 0x64331380UL, \
"address of compartment string table") \
_ELF_DEFINE_DT(DT_C18NSTRTABSZ, 0x64331381UL, \
"size of the compartment string table") \
_ELF_DEFINE_DT(DT_HIOS, 0x6FFFF000UL, \
"end of OS-specific types") \
_ELF_DEFINE_DT(DT_VALRNGLO, 0x6FFFFD00UL, \
Expand Down Expand Up @@ -965,6 +969,8 @@ _ELF_DEFINE_PT(PT_PHDR, 6, \
_ELF_DEFINE_PT(PT_TLS, 7, "thread local storage") \
_ELF_DEFINE_PT(PT_LOOS, 0x60000000UL, \
"start of OS-specific range") \
_ELF_DEFINE_PT(PT_COMPARTMENT, 0x64331380UL, \
"Sub-object compartment") \
_ELF_DEFINE_PT(PT_CHERI_BOUNDS, 0x64348450UL, \
"CHERI PCC bounds") \
_ELF_DEFINE_PT(PT_SUNW_UNWIND, 0x6464E550UL, \
Expand Down
5 changes: 5 additions & 0 deletions contrib/elftoolchain/elfdump/elfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ d_tags(uint64_t tag)
case DT_FLAGS: return "DT_FLAGS";
case DT_PREINIT_ARRAY: return "DT_PREINIT_ARRAY"; /* XXX DT_ENCODING */
case DT_PREINIT_ARRAYSZ:return "DT_PREINIT_ARRAYSZ";
case DT_C18NSTRTAB: return "DT_C18NSTRTAB";
case DT_C18NSTRTABSZ: return "DT_C18NSTRTABSZ";
/* 0x6000000D - 0x6ffff000 operating system-specific semantics */
case 0x6ffffdf5: return "DT_GNU_PRELINKED";
case 0x6ffffdf6: return "DT_GNU_CONFLICTSZ";
Expand Down Expand Up @@ -351,6 +353,7 @@ elf_phdr_type_str(unsigned int type)
case PT_SHLIB: return "PT_SHLIB";
case PT_PHDR: return "PT_PHDR";
case PT_TLS: return "PT_TLS";
case PT_COMPARTMENT: return "PT_COMPARTMENT";
case PT_CHERI_BOUNDS: return "PT_CHERI_BOUNDS";
case PT_GNU_EH_FRAME: return "PT_GNU_EH_FRAME";
case PT_GNU_STACK: return "PT_GNU_STACK";
Expand Down Expand Up @@ -1667,6 +1670,7 @@ elf_print_dynamic(struct elfdump *ed)
case DT_VERNEED:
case DT_VERNEEDNUM:
case DT_VERSYM:
case DT_C18NSTRTABSZ:
if (ed->flags & SOLARIS_FMT)
PRT("%#jx\n", (uintmax_t)dyn.d_un.d_val);
else
Expand All @@ -1683,6 +1687,7 @@ elf_print_dynamic(struct elfdump *ed)
case DT_REL:
case DT_JMPREL:
case DT_DEBUG:
case DT_C18NSTRTAB:
if (ed->flags & SOLARIS_FMT)
PRT("%#jx\n", (uintmax_t)dyn.d_un.d_ptr);
else
Expand Down
5 changes: 5 additions & 0 deletions contrib/elftoolchain/readelf/readelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ phdr_type(unsigned int mach, unsigned int ptype)
case PT_SHLIB: return "SHLIB";
case PT_PHDR: return "PHDR";
case PT_TLS: return "TLS";
case PT_COMPARTMENT: return "COMPARTMENT";
case PT_CHERI_BOUNDS: return "CHERI_BOUNDS";
case PT_GNU_EH_FRAME: return "GNU_EH_FRAME";
case PT_GNU_STACK: return "GNU_STACK";
Expand Down Expand Up @@ -886,6 +887,8 @@ dt_type(unsigned int mach, unsigned int dtype)
case DT_SUNW_FILTER: return "SUNW_FILTER";
case DT_SUNW_CAP: return "SUNW_CAP";
case DT_SUNW_ASLR: return "SUNW_ASLR";
case DT_C18NSTRTAB: return "C18NSTRTAB";
case DT_C18NSTRTABSZ: return "C18NSTRTABSZ";
case DT_CHECKSUM: return "CHECKSUM";
case DT_PLTPADSZ: return "PLTPADSZ";
case DT_MOVEENT: return "MOVEENT";
Expand Down Expand Up @@ -3031,6 +3034,7 @@ dump_dyn_val(struct readelf *re, GElf_Dyn *dyn, uint32_t stab)
case DT_GNU_HASH:
case DT_GNU_LIBLIST:
case DT_GNU_CONFLICT:
case DT_C18NSTRTAB:
printf(" 0x%jx\n", (uintmax_t) dyn->d_un.d_val);
break;
case DT_PLTRELSZ:
Expand All @@ -3045,6 +3049,7 @@ dump_dyn_val(struct readelf *re, GElf_Dyn *dyn, uint32_t stab)
case DT_FINI_ARRAYSZ:
case DT_GNU_CONFLICTSZ:
case DT_GNU_LIBLISTSZ:
case DT_C18NSTRTABSZ:
printf(" %ju (bytes)\n", (uintmax_t) dyn->d_un.d_val);
break;
case DT_RELACOUNT:
Expand Down

0 comments on commit 341a20c

Please sign in to comment.