Skip to content

Commit 7ab04d7

Browse files
openeuler-ci-botgitee-org
authored andcommitted
!188 compiler & openEuler oeaware schedule opt
From: @flyahead1 Reviewed-by: @liyunfei33 Signed-off-by: @liyunfei33
2 parents 0c7685b + fc738b9 commit 7ab04d7

File tree

6 files changed

+48
-0
lines changed

6 files changed

+48
-0
lines changed

lld/ELF/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ struct Config {
338338
uint8_t zStartStopVisibility;
339339
bool zText;
340340
bool zRetpolineplt;
341+
int8_t zOeawarePolicy;
341342
bool zWxneeded;
342343
DiscardPolicy discard;
343344
GnuStackKind zGnustack;

lld/ELF/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ static void readConfigs(opt::InputArgList &args) {
15011501
config->zStartStopVisibility = getZStartStopVisibility(args);
15021502
config->zText = getZFlag(args, "text", "notext", true);
15031503
config->zWxneeded = hasZOption(args, "wxneeded");
1504+
config->zOeawarePolicy = args::getZOptionValue(args, OPT_z, "oeaware-policy", -1);
15041505
setUnresolvedSymbolPolicy(args);
15051506
config->power10Stubs = args.getLastArgValue(OPT_power10_stubs_eq) != "no";
15061507

lld/ELF/SyntheticSections.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,8 +4922,21 @@ template <class ELFT> void elf::createSyntheticSections() {
49224922
add(*in.shStrTab);
49234923
if (in.strTab)
49244924
add(*in.strTab);
4925+
if (config->zOeawarePolicy != -1) {
4926+
in.oeaware = std::make_unique<OeAware>();
4927+
add(*in.oeaware);
4928+
}
4929+
}
4930+
4931+
void OeAware::writeTo(uint8_t *buf) {
4932+
if (config->zOeawarePolicy != -1)
4933+
write32(buf, config->zOeawarePolicy);
49254934
}
49264935

4936+
size_t OeAware::getSize() const { return 4; }
4937+
4938+
void OeAware::finalizeContents() {}
4939+
49274940
InStruct elf::in;
49284941

49294942
std::vector<Partition> elf::partitions;

lld/ELF/SyntheticSections.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,20 @@ class MemtagGlobalDescriptors final : public SyntheticSection {
14251425
SmallVector<const Symbol *, 0> symbols;
14261426
};
14271427

1428+
class OeAware : public SyntheticSection {
1429+
public:
1430+
OeAware()
1431+
: SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
1432+
llvm::ELF::SHT_NOTE, /*alignment=*/4, ".LLVM4OE_oeAware")
1433+
{}
1434+
void writeTo(uint8_t *buf) override;
1435+
size_t getSize() const override;
1436+
void finalizeContents() override;
1437+
1438+
private:
1439+
uint64_t size;
1440+
};
1441+
14281442
template <class ELFT> void createSyntheticSections();
14291443
InputSection *createInterpSection();
14301444
MergeInputSection *createCommentSection();
@@ -1512,6 +1526,7 @@ struct InStruct {
15121526
std::unique_ptr<StringTableSection> strTab;
15131527
std::unique_ptr<SymbolTableBaseSection> symTab;
15141528
std::unique_ptr<SymtabShndxSection> symTabShndx;
1529+
std::unique_ptr<SyntheticSection> oeaware;
15151530

15161531
void reset();
15171532
};

lld/ELF/Writer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
19611961
llvm::TimeTraceScope timeScope("Finalize synthetic sections");
19621962

19631963
finalizeSynthetic(in.bss.get());
1964+
finalizeSynthetic(in.oeaware.get());
19641965
finalizeSynthetic(in.bssRelRo.get());
19651966
finalizeSynthetic(in.symTabShndx.get());
19661967
finalizeSynthetic(in.shStrTab.get());

lld/test/ELF/oeaware.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# REQUIRES: target=aarch64{{.*}}
2+
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
3+
# RUN: ld.lld %t.o -o %ta -z oeaware-policy=1
4+
# RUN: llvm-objdump -j .LLVM4OE_oeAware %ta -d | FileCheck %s
5+
6+
# CHECK: <.LLVM4OE_oeAware>:
7+
# CHECK-NEXT: 00000001
8+
9+
# RUN: ld.lld %t.o -o %tb -z oeaware-policy=2
10+
# RUN: llvm-objdump -j .LLVM4OE_oeAware %tb -d | FileCheck %s --check-prefix=OPTION
11+
12+
# OPTION: <.LLVM4OE_oeAware>:
13+
# OPTION-NEXT: 00000002
14+
15+
.globl _start
16+
_start: nop
17+
.bss; .byte 0

0 commit comments

Comments
 (0)