@@ -65,7 +65,7 @@ template <class ELFT> class Writer {
65
65
void checkExecuteOnly ();
66
66
void setReservedSymbolSections ();
67
67
68
- std::vector <PhdrEntry *> createPhdrs (Partition &part);
68
+ SmallVector <PhdrEntry *, 0 > createPhdrs (Partition &part);
69
69
void addPhdrForSection (Partition &part, unsigned shType, unsigned pType,
70
70
unsigned pFlags);
71
71
void assignFileOffsets ();
@@ -100,7 +100,7 @@ template <class ELFT> void elf::writeResult() {
100
100
Writer<ELFT>().run ();
101
101
}
102
102
103
- static void removeEmptyPTLoad (std::vector <PhdrEntry *> &phdrs) {
103
+ static void removeEmptyPTLoad (SmallVector <PhdrEntry *, 0 > &phdrs) {
104
104
auto it = std::stable_partition (
105
105
phdrs.begin (), phdrs.end (), [&](const PhdrEntry *p) {
106
106
if (p->p_type != PT_LOAD)
@@ -1170,9 +1170,9 @@ static bool shouldSkip(SectionCommand *cmd) {
1170
1170
// We want to place orphan sections so that they share as much
1171
1171
// characteristics with their neighbors as possible. For example, if
1172
1172
// both are rw, or both are tls.
1173
- static std::vector <SectionCommand *>::iterator
1174
- findOrphanPos (std::vector <SectionCommand *>::iterator b,
1175
- std::vector <SectionCommand *>::iterator e) {
1173
+ static SmallVectorImpl <SectionCommand *>::iterator
1174
+ findOrphanPos (SmallVectorImpl <SectionCommand *>::iterator b,
1175
+ SmallVectorImpl <SectionCommand *>::iterator e) {
1176
1176
OutputSection *sec = cast<OutputSection>(*e);
1177
1177
1178
1178
// Find the first element that has as close a rank as possible.
@@ -1332,8 +1332,8 @@ static DenseMap<const InputSectionBase *, int> buildSectionOrder() {
1332
1332
static void
1333
1333
sortISDBySectionOrder (InputSectionDescription *isd,
1334
1334
const DenseMap<const InputSectionBase *, int > &order) {
1335
- std::vector <InputSection *> unorderedSections;
1336
- std::vector <std::pair<InputSection *, int >> orderedSections;
1335
+ SmallVector <InputSection *, 0 > unorderedSections;
1336
+ SmallVector <std::pair<InputSection *, int >, 0 > orderedSections;
1337
1337
uint64_t unorderedSize = 0 ;
1338
1338
1339
1339
for (InputSection *isec : isd->sections ) {
@@ -1766,10 +1766,10 @@ template <class ELFT> void Writer<ELFT>::optimizeBasicBlockJumps() {
1766
1766
// jump to the following section as it is not required.
1767
1767
// 2. If there are two consecutive jump instructions, it checks
1768
1768
// if they can be flipped and one can be deleted.
1769
- for (OutputSection *os : outputSections) {
1770
- if (!(os ->flags & SHF_EXECINSTR))
1769
+ for (OutputSection *osec : outputSections) {
1770
+ if (!(osec ->flags & SHF_EXECINSTR))
1771
1771
continue ;
1772
- std::vector <InputSection *> sections = getInputSections (os );
1772
+ SmallVector <InputSection *, 0 > sections = getInputSections (*osec );
1773
1773
std::vector<unsigned > result (sections.size ());
1774
1774
// Delete all fall through jump instructions. Also, check if two
1775
1775
// consecutive jump instructions can be flipped so that a fall
@@ -1790,11 +1790,9 @@ template <class ELFT> void Writer<ELFT>::optimizeBasicBlockJumps() {
1790
1790
1791
1791
fixSymbolsAfterShrinking ();
1792
1792
1793
- for (OutputSection *os : outputSections) {
1794
- std::vector<InputSection *> sections = getInputSections (os);
1795
- for (InputSection *is : sections)
1793
+ for (OutputSection *osec : outputSections)
1794
+ for (InputSection *is : getInputSections (*osec))
1796
1795
is->trim ();
1797
- }
1798
1796
}
1799
1797
1800
1798
// In order to allow users to manipulate linker-synthesized sections,
@@ -2165,11 +2163,12 @@ template <class ELFT> void Writer<ELFT>::checkExecuteOnly() {
2165
2163
if (!config->executeOnly )
2166
2164
return ;
2167
2165
2168
- for (OutputSection *os : outputSections)
2169
- if (os ->flags & SHF_EXECINSTR)
2170
- for (InputSection *isec : getInputSections (os ))
2166
+ for (OutputSection *osec : outputSections)
2167
+ if (osec ->flags & SHF_EXECINSTR)
2168
+ for (InputSection *isec : getInputSections (*osec ))
2171
2169
if (!(isec->flags & SHF_EXECINSTR))
2172
- error (" cannot place " + toString (isec) + " into " + toString (os->name ) +
2170
+ error (" cannot place " + toString (isec) + " into " +
2171
+ toString (osec->name ) +
2173
2172
" : -execute-only does not support intermingling data and code" );
2174
2173
}
2175
2174
@@ -2259,8 +2258,8 @@ static uint64_t computeFlags(uint64_t flags) {
2259
2258
// Decide which program headers to create and which sections to include in each
2260
2259
// one.
2261
2260
template <class ELFT >
2262
- std::vector <PhdrEntry *> Writer<ELFT>::createPhdrs(Partition &part) {
2263
- std::vector <PhdrEntry *> ret;
2261
+ SmallVector <PhdrEntry *, 0 > Writer<ELFT>::createPhdrs(Partition &part) {
2262
+ SmallVector <PhdrEntry *, 0 > ret;
2264
2263
auto addHdr = [&](unsigned type, unsigned flags) -> PhdrEntry * {
2265
2264
ret.push_back (make<PhdrEntry>(type, flags));
2266
2265
return ret.back ();
0 commit comments