mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 01:15:50 +08:00
[ELF] - Linkerscript: implemented SORT_BY_INIT_PRIORITY.
This is PR30386, SORT_BY_INIT_PRIORITY is a keyword can be used to sort sections by numerical value of the GCC init_priority attribute encoded in the section name. Differential revision: https://reviews.llvm.org/D24611 llvm-svn: 281646
This commit is contained in:
@@ -110,6 +110,10 @@ static bool fileMatches(const InputSectionDescription *Desc,
|
||||
!const_cast<Regex &>(Desc->ExcludedFileRe).match(Filename);
|
||||
}
|
||||
|
||||
static bool comparePriority(InputSectionData *A, InputSectionData *B) {
|
||||
return getPriority(A->Name) < getPriority(B->Name);
|
||||
}
|
||||
|
||||
static bool compareName(InputSectionData *A, InputSectionData *B) {
|
||||
return A->Name < B->Name;
|
||||
}
|
||||
@@ -123,6 +127,8 @@ static bool compareAlignment(InputSectionData *A, InputSectionData *B) {
|
||||
|
||||
static std::function<bool(InputSectionData *, InputSectionData *)>
|
||||
getComparator(SortKind K) {
|
||||
if (K == SortByPriority)
|
||||
return comparePriority;
|
||||
if (K == SortByName)
|
||||
return compareName;
|
||||
return compareAlignment;
|
||||
@@ -967,6 +973,8 @@ SortKind ScriptParser::readSortKind() {
|
||||
return SortByName;
|
||||
if (skip("SORT_BY_ALIGNMENT"))
|
||||
return SortByAlignment;
|
||||
if (skip("SORT_BY_INIT_PRIORITY"))
|
||||
return SortByPriority;
|
||||
return SortNone;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user