@@ -583,14 +583,14 @@ void CheriCapRelocsSection::writeTo(uint8_t *buf) {
583583 invokeELFT (writeToImpl, buf);
584584}
585585
586- CheriCapTableSection::CheriCapTableSection ()
586+ MipsCheriCapTableSection::MipsCheriCapTableSection ()
587587 : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
588588 config->capabilitySize, " .captable" ) {
589589 assert (config->capabilitySize > 0 );
590590 this ->entsize = config->capabilitySize ;
591591}
592592
593- void CheriCapTableSection ::writeTo (uint8_t * buf) {
593+ void MipsCheriCapTableSection ::writeTo (uint8_t * buf) {
594594 // Capability part should be filled with all zeros and crt_init_globals fills
595595 // it in. For the TLS part, assignValuesAndAddCapTableSymbols adds any static
596596 // relocations needed, and should be procesed by relocateAlloc.
@@ -603,8 +603,8 @@ static Defined *findMatchingFunction(const InputSectionBase *isec,
603603 return isec->getEnclosingFunction (symOffset);
604604}
605605
606- CheriCapTableSection ::CaptableMap &
607- CheriCapTableSection ::getCaptableMapForFileAndOffset (
606+ MipsCheriCapTableSection ::CaptableMap &
607+ MipsCheriCapTableSection ::getCaptableMapForFileAndOffset (
608608 const InputSectionBase *isec, uint64_t offset) {
609609 if (LLVM_LIKELY (config->capTableScope == CapTableScopePolicy::All))
610610 return globalEntries;
@@ -626,17 +626,18 @@ CheriCapTableSection::getCaptableMapForFileAndOffset(
626626 return globalEntries;
627627}
628628
629- void CheriCapTableSection::addEntry (Symbol &sym, RelExpr expr,
630- InputSectionBase *isec, uint64_t offset) {
629+ void MipsCheriCapTableSection::addEntry (Symbol &sym, RelExpr expr,
630+ InputSectionBase *isec,
631+ uint64_t offset) {
631632 // FIXME: can this be called from multiple threads?
632633 CapTableIndex idx;
633634 idx.needsSmallImm = false ;
634635 idx.usedInCallExpr = false ;
635636 idx.firstUse = SymbolAndOffset (isec, offset);
636637 assert (!idx.firstUse ->symOrSec .isNull ());
637638 switch (expr) {
638- case R_CHERI_CAPABILITY_TABLE_INDEX_SMALL_IMMEDIATE :
639- case R_CHERI_CAPABILITY_TABLE_INDEX_CALL_SMALL_IMMEDIATE :
639+ case R_MIPS_CHERI_CAPTAB_INDEX_SMALL_IMMEDIATE :
640+ case R_MIPS_CHERI_CAPTAB_INDEX_CALL_SMALL_IMMEDIATE :
640641 idx.needsSmallImm = true ;
641642 break ;
642643 default :
@@ -648,8 +649,8 @@ void CheriCapTableSection::addEntry(Symbol &sym, RelExpr expr,
648649 // not used as a function pointer and therefore does not need a unique
649650 // address (plt stub) across all DSOs.
650651 switch (expr) {
651- case R_CHERI_CAPABILITY_TABLE_INDEX_CALL :
652- case R_CHERI_CAPABILITY_TABLE_INDEX_CALL_SMALL_IMMEDIATE :
652+ case R_MIPS_CHERI_CAPTAB_INDEX_CALL :
653+ case R_MIPS_CHERI_CAPTAB_INDEX_CALL_SMALL_IMMEDIATE :
653654 if (!sym.isFunc () && !sym.isUndefWeak ()) {
654655 CheriCapRelocLocation loc{isec, offset};
655656 std::string msg = " call relocation against non-function symbol " + verboseToString (&sym, 0 ) +
@@ -689,25 +690,25 @@ void CheriCapTableSection::addEntry(Symbol &sym, RelExpr expr,
689690 }
690691}
691692
692- void CheriCapTableSection ::addDynTlsEntry (Symbol &sym) {
693+ void MipsCheriCapTableSection ::addDynTlsEntry (Symbol &sym) {
693694 dynTlsEntries.map .insert (std::make_pair (&sym, CapTableIndex ()));
694695}
695696
696- void CheriCapTableSection ::addTlsIndex () {
697+ void MipsCheriCapTableSection ::addTlsIndex () {
697698 dynTlsEntries.map .insert (std::make_pair (nullptr , CapTableIndex ()));
698699}
699700
700- void CheriCapTableSection ::addTlsEntry (Symbol &sym) {
701+ void MipsCheriCapTableSection ::addTlsEntry (Symbol &sym) {
701702 tlsEntries.map .insert (std::make_pair (&sym, CapTableIndex ()));
702703}
703704
704- uint32_t CheriCapTableSection ::getIndex (const Symbol &sym,
705- const InputSectionBase *isec,
706- uint64_t offset) const {
705+ uint32_t MipsCheriCapTableSection ::getIndex (const Symbol &sym,
706+ const InputSectionBase *isec,
707+ uint64_t offset) const {
707708 assert (valuesAssigned && " getIndex called before index assignment" );
708709 const CaptableMap &entries =
709- const_cast <CheriCapTableSection *>(this )-> getCaptableMapForFileAndOffset (
710- isec, offset);
710+ const_cast <MipsCheriCapTableSection *>(this )
711+ -> getCaptableMapForFileAndOffset ( isec, offset);
711712 auto it = entries.map .find (const_cast <Symbol *>(&sym));
712713 assert (entries.firstIndex != std::numeric_limits<uint64_t >::max () &&
713714 " First index not set yet?" );
@@ -719,31 +720,31 @@ uint32_t CheriCapTableSection::getIndex(const Symbol &sym,
719720 return *it->second .index - entries.firstIndex ;
720721}
721722
722- uint32_t CheriCapTableSection ::getDynTlsOffset (const Symbol &sym) const {
723+ uint32_t MipsCheriCapTableSection ::getDynTlsOffset (const Symbol &sym) const {
723724 assert (valuesAssigned && " getDynTlsOffset called before index assignment" );
724725 auto it = dynTlsEntries.map .find (const_cast <Symbol *>(&sym));
725726 assert (it != dynTlsEntries.map .end ());
726727 return *it->second .index * config->wordsize ;
727728}
728729
729- uint32_t CheriCapTableSection ::getTlsIndexOffset () const {
730+ uint32_t MipsCheriCapTableSection ::getTlsIndexOffset () const {
730731 assert (valuesAssigned && " getTlsIndexOffset called before index assignment" );
731732 auto it = dynTlsEntries.map .find (nullptr );
732733 assert (it != dynTlsEntries.map .end ());
733734 return *it->second .index * config->wordsize ;
734735}
735736
736- uint32_t CheriCapTableSection ::getTlsOffset (const Symbol &sym) const {
737+ uint32_t MipsCheriCapTableSection ::getTlsOffset (const Symbol &sym) const {
737738 assert (valuesAssigned && " getTlsOffset called before index assignment" );
738739 auto it = tlsEntries.map .find (const_cast <Symbol *>(&sym));
739740 assert (it != tlsEntries.map .end ());
740741 return *it->second .index * config->wordsize ;
741742}
742743
743744template <class ELFT >
744- uint64_t CheriCapTableSection ::assignIndices (uint64_t startIndex,
745- CaptableMap &entries,
746- const Twine &symContext) {
745+ uint64_t MipsCheriCapTableSection ::assignIndices (uint64_t startIndex,
746+ CaptableMap &entries,
747+ const Twine &symContext) {
747748 // Usually StartIndex will be zero (one global captable) but if we are
748749 // compiling with per-file/per-function
749750 uint64_t smallEntryCount = 0 ;
@@ -846,7 +847,7 @@ uint64_t CheriCapTableSection::assignIndices(uint64_t startIndex,
846847 RelocationBaseSection *dynRelSec =
847848 it.second .usedInCallExpr ? in.relaPlt .get () : mainPart->relaDyn .get ();
848849 addCapabilityRelocation<ELFT>(
849- targetSym, elfCapabilityReloc, in.cheriCapTable .get (), off,
850+ targetSym, elfCapabilityReloc, in.mipsCheriCapTable .get (), off,
850851 R_CHERI_CAPABILITY, 0 , it.second .usedInCallExpr ,
851852 [&]() {
852853 return (" \n >>> referenced by " + refName + " \n >>> first used in " +
@@ -860,7 +861,7 @@ uint64_t CheriCapTableSection::assignIndices(uint64_t startIndex,
860861}
861862
862863template <class ELFT >
863- void CheriCapTableSection ::assignValuesAndAddCapTableSymbols () {
864+ void MipsCheriCapTableSection ::assignValuesAndAddCapTableSymbols () {
864865 // First assign the global indices (which will usually be the only ones)
865866 uint64_t assignedEntries = assignIndices<ELFT>(0 , globalEntries, " " );
866867 if (LLVM_UNLIKELY (config->capTableScope != CapTableScopePolicy::All)) {
@@ -948,22 +949,22 @@ void CheriCapTableSection::assignValuesAndAddCapTableSymbols() {
948949}
949950
950951template void
951- CheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF32LE>();
952+ MipsCheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF32LE>();
952953template void
953- CheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF32BE>();
954+ MipsCheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF32BE>();
954955template void
955- CheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF64LE>();
956+ MipsCheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF64LE>();
956957template void
957- CheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF64BE>();
958+ MipsCheriCapTableSection ::assignValuesAndAddCapTableSymbols<ELF64BE>();
958959
959- CheriCapTableMappingSection::CheriCapTableMappingSection ()
960+ MipsCheriCapTableMappingSection::MipsCheriCapTableMappingSection ()
960961 : SyntheticSection(SHF_ALLOC, SHT_PROGBITS, 8 , " .captable_mapping" ) {
961962 assert (config->capabilitySize > 0 );
962963 this ->entsize = sizeof (CaptableMappingEntry);
963964 static_assert (sizeof (CaptableMappingEntry) == 24 , " " );
964965}
965966
966- size_t CheriCapTableMappingSection ::getSize () const {
967+ size_t MipsCheriCapTableMappingSection ::getSize () const {
967968 assert (config->capTableScope != CapTableScopePolicy::All);
968969 if (!isNeeded ())
969970 return 0 ;
@@ -980,9 +981,9 @@ size_t CheriCapTableMappingSection::getSize() const {
980981 return count * sizeof (CaptableMappingEntry);
981982}
982983
983- void CheriCapTableMappingSection ::writeTo (uint8_t *buf) {
984+ void MipsCheriCapTableMappingSection ::writeTo (uint8_t *buf) {
984985 assert (config->capTableScope != CapTableScopePolicy::All);
985- if (!in.cheriCapTable )
986+ if (!in.mipsCheriCapTable )
986987 return ;
987988 if (!in.symTab ) {
988989 error (" Cannot write " + this ->name + " without .symtab section!" );
@@ -997,14 +998,14 @@ void CheriCapTableMappingSection::writeTo(uint8_t *buf) {
997998 Symbol* sym = ste.sym ;
998999 if (!sym->isDefined () || !sym->isFunc ())
9991000 continue ;
1000- const CheriCapTableSection ::CaptableMap *capTableMap = nullptr ;
1001+ const MipsCheriCapTableSection ::CaptableMap *capTableMap = nullptr ;
10011002 if (config->capTableScope == CapTableScopePolicy::Function) {
1002- auto it = in.cheriCapTable ->perFunctionEntries .find (sym);
1003- if (it != in.cheriCapTable ->perFunctionEntries .end ())
1003+ auto it = in.mipsCheriCapTable ->perFunctionEntries .find (sym);
1004+ if (it != in.mipsCheriCapTable ->perFunctionEntries .end ())
10041005 capTableMap = &it->second ;
10051006 } else if (config->capTableScope == CapTableScopePolicy::File) {
1006- auto it = in.cheriCapTable ->perFileEntries .find (sym->file );
1007- if (it != in.cheriCapTable ->perFileEntries .end ())
1007+ auto it = in.mipsCheriCapTable ->perFileEntries .find (sym->file );
1008+ if (it != in.mipsCheriCapTable ->perFileEntries .end ())
10081009 capTableMap = &it->second ;
10091010 } else {
10101011 llvm_unreachable (" Invalid mode!" );
0 commit comments