ELF: Simplify isRelRoDataSection and rename the text file
PR #148920 was merged before I could share my comments. * Fix the text filename. There are other minor suggestions, but can be done in #148985 * Make `isRelRoDataSection` concise, to be consistent with the majority of helper functions.
This commit is contained in:
parent
90944b85c5
commit
f97adea477
@ -553,24 +553,16 @@ template <class ELFT> void Writer<ELFT>::addSectionSymbols() {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if the section is a data section that's read only and
|
||||
// relocatable per its section name.
|
||||
// Returns true if this is a variant of .data.rel.ro.
|
||||
static bool isRelRoDataSection(Ctx &ctx, StringRef secName) {
|
||||
// The section name should start with ".data.rel.ro".
|
||||
if (!secName.consume_front(".data.rel.ro"))
|
||||
return false;
|
||||
|
||||
// If the section name is .data.rel.ro, it is a relocatable read-only data
|
||||
// section.
|
||||
if (secName.empty())
|
||||
return true;
|
||||
// If -z keep-data-section-prefix is given, '.data.rel.ro.hot' and
|
||||
// '.data.rel.ro.unlikely' are considered a split of '.data.rel.ro' based on
|
||||
// hotness.
|
||||
if (ctx.arg.zKeepDataSectionPrefix) {
|
||||
// If -z keep-data-section-prefix is specified, additionally allow
|
||||
// '.data.rel.ro.hot' and '.data.rel.ro.unlikely'.
|
||||
if (ctx.arg.zKeepDataSectionPrefix)
|
||||
return secName == ".hot" || secName == ".unlikely";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
## .data.rel.ro.split -> .data.rel.ro
|
||||
## .data.rel.ro -> .data.rel.ro
|
||||
## .data.rel.ro.hot -> .data.rel.ro.hot
|
||||
## .data.rel.ro.unlikely -> .data.rel.ro.unlikely
|
||||
## .data.rel.ro.unlikely -> .data.rel.ro.unlikely
|
||||
# LS: .text
|
||||
# LS-NEXT: .data.rel.ro.hot .data.rel.ro .data.rel.ro.unlikely .relro_padding
|
||||
# LS-NEXT: .data .bss
|
||||
@ -61,7 +61,7 @@
|
||||
SECTIONS {
|
||||
.data.rel.ro.hot : { *(.data.rel.ro.hot) }
|
||||
.data.rel.ro : { .data.rel.ro }
|
||||
.data.rel.ro.unlikely : { *(.data.rel.ro.unlikely) }
|
||||
.data.rel.ro.unlikely : { *(.data.rel.ro.unlikely) }
|
||||
} INSERT AFTER .text
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user