bool alignSegments() const { return _alignSegments; }
void setAlignSegments(bool align) { _alignSegments = align; }
+ /// \brief Enable new dtags.
+ /// If this flag is set lld emits DT_RUNPATH instead of
+ /// DT_RUNPATH. They are functionally equivalent except for
+ /// the following two differences:
+ /// - DT_RUNPATH is searched after LD_LIBRARY_PATH, while
+ /// DT_RPATH is searched before.
+ /// - DT_RUNPATH is used only to search for direct dependencies
+ /// of the object it's contained in, while DT_RPATH is used
+ /// for indirect dependencies as well.
+ bool getEnableNewDtags() const { return _enableNewDtags; }
+ void setEnableNewDtags(bool e) { _enableNewDtags = e; }
+
/// \brief Strip symbols.
bool stripSymbols() const { return _stripSymbols; }
void setStripSymbols(bool strip) { _stripSymbols = strip; }
bool _demangle = true;
bool _stripSymbols = false;
bool _alignSegments = true;
+ bool _enableNewDtags = false;
bool _collectStats = false;
bool _armTarget1Rel = false;
uint64_t _maxPageSize = 0x1000;
ctx->addRpathLink(path);
}
+ // Enable new dynamic tags.
+ if (parsedArgs->hasArg(OPT_enable_newdtags))
+ ctx->setEnableNewDtags(true);
+
// Support --wrap option.
for (auto *arg : parsedArgs->filtered(OPT_wrap))
ctx->addWrapForSymbol(arg->getValue());
//===----------------------------------------------------------------------===//
def grp_customopts : OptionGroup<"opts">,
HelpText<"CUSTOM OPTIONS">;
+def disable_newdtags: Flag<["--"], "disable-new-dtags">,
+ HelpText<"Disable new dynamic tags">,
+ Group<grp_customopts>;
+def enable_newdtags: Flag<["--"], "enable-new-dtags">,
+ HelpText<"Enable new dynamic tags">,
+ Group<grp_customopts>;
def rosegment: Flag<["--"], "rosegment">,
HelpText<"Put read-only non-executable sections in their own segment">,
Group<grp_customopts>;
auto rpath = new (_alloc) std::string(join(rpathList.begin(),
rpathList.end(), ":"));
Elf_Dyn dyn;
- dyn.d_tag = DT_RPATH;
+ dyn.d_tag = _ctx.getEnableNewDtags() ? DT_RUNPATH : DT_RPATH;
dyn.d_un.d_val = _dynamicStringTable->addString(*rpath);
_dynamicTable->addEntry(dyn);
}