Skip to content

Commit

Permalink
[LLF][ELF] - Support -z global.
Browse files Browse the repository at this point in the history
-z global is a flag used on Android (see D49198).

Differential revision: https://reviews.llvm.org/D49374

llvm-svn: 340802
  • Loading branch information
George Rimar committed Aug 28, 2018
1 parent d2f7b04 commit 27bbe7d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions lld/ELF/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct Configuration {
bool ZCombreloc;
bool ZCopyreloc;
bool ZExecstack;
bool ZGlobal;
bool ZHazardplt;
bool ZInitfirst;
bool ZKeepTextSectionPrefix;
Expand Down
9 changes: 5 additions & 4 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ static bool getZFlag(opt::InputArgList &Args, StringRef K1, StringRef K2,

static bool isKnown(StringRef S) {
return S == "combreloc" || S == "copyreloc" || S == "defs" ||
S == "execstack" || S == "hazardplt" || S == "initfirst" ||
S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" ||
S == "nodlopen" || S == "noexecstack" ||
S == "execstack" || S == "global" || S == "hazardplt" ||
S == "initfirst" || S == "keep-text-section-prefix" || S == "lazy" ||
S == "muldefs" || S == "nocombreloc" || S == "nocopyreloc" ||
S == "nodelete" || S == "nodlopen" || S == "noexecstack" ||
S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" ||
S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" ||
S == "rodynamic" || S == "text" || S == "wxneeded" ||
Expand Down Expand Up @@ -833,6 +833,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->ZCombreloc = getZFlag(Args, "combreloc", "nocombreloc", true);
Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true);
Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false);
Config->ZGlobal = hasZOption(Args, "global");
Config->ZHazardplt = hasZOption(Args, "hazardplt");
Config->ZInitfirst = hasZOption(Args, "initfirst");
Config->ZKeepTextSectionPrefix = getZFlag(
Expand Down
2 changes: 2 additions & 0 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,8 @@ template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
uint32_t DtFlags1 = 0;
if (Config->Bsymbolic)
DtFlags |= DF_SYMBOLIC;
if (Config->ZGlobal)
DtFlags1 |= DF_1_GLOBAL;
if (Config->ZInitfirst)
DtFlags1 |= DF_1_INITFIRST;
if (Config->ZNodelete)
Expand Down
5 changes: 3 additions & 2 deletions lld/test/ELF/dt_flags.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -shared %t -o %t.so

# RUN: ld.lld -z initfirst -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
# RUN: ld.lld -z global -z initfirst -z now -z nodelete -z nodlopen -z origin \
# RUN: -Bsymbolic %t %t.so -o %t1
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s

# RUN: ld.lld %t %t.so -o %t2
Expand All @@ -14,7 +15,7 @@

# FLAGS: DynamicSection [
# FLAGS: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE INITFIRST NOOPEN ORIGIN
# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL NODELETE INITFIRST NOOPEN ORIGIN
# FLAGS: ]

# CHECK: DynamicSection [
Expand Down

0 comments on commit 27bbe7d

Please sign in to comment.