openbsd-ports/devel/llvm/patches/patch-tools_lld_ELF_SyntheticSections_cpp
ajacoutot 9b536d7f79 Sync with base:
- Accept both `--foo bar` and `--foo=bar` styles options.
- Add support for -z initfirst.
- Generate __data_start symbol that marks the start of .data when __data_start
  is referenced from code being linked.

From Brad (maintainer)
2018-10-25 09:25:38 +00:00

47 lines
2.1 KiB
Plaintext

$OpenBSD: patch-tools_lld_ELF_SyntheticSections_cpp,v 1.8 2018/10/25 09:25:38 ajacoutot Exp $
- Add support for -z initfirst.
- When merging sections into the output, lld tries to adjust the alignment of
the section to be at least as large as the entry size of the section.
This causes a later check that validates the alignment to fail if the
entry size isn't a power of two. This happens when building some of the
java support code in ports gcc. Fix this by sticking to the original
alignment if the entry size isn't a power of two.
- Work around a bug where discarding the .ARM.exidx section in the armv7 kernel
linker script makes ld.lld(1) crash. This has been fixed in a different
(proper?) way upstream but backporting their fix is a bit too invasive.
Index: tools/lld/ELF/SyntheticSections.cpp
--- tools/lld/ELF/SyntheticSections.cpp.orig
+++ tools/lld/ELF/SyntheticSections.cpp
@@ -1034,6 +1034,8 @@ template <class ELFT> void DynamicSection<ELFT>::final
uint32_t DtFlags1 = 0;
if (Config->Bsymbolic)
DtFlags |= DF_SYMBOLIC;
+ if (Config->ZInitfirst)
+ DtFlags1 |= DF_1_INITFIRST;
if (Config->ZNodelete)
DtFlags1 |= DF_1_NODELETE;
if (Config->ZNodlopen)
@@ -2512,7 +2514,9 @@ void elf::mergeSections() {
continue;
StringRef OutsecName = getOutputSectionName(MS);
- uint32_t Alignment = std::max<uint32_t>(MS->Alignment, MS->Entsize);
+ uint32_t Alignment = MS->Alignment;
+ if (isPowerOf2_32(MS->Entsize))
+ Alignment = std::max<uint32_t>(Alignment, MS->Entsize);
auto I = llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) {
// While we could create a single synthetic section for two different
@@ -2571,6 +2575,9 @@ void ARMExidxSentinelSection::writeTo(uint8_t *Buf) {
// The sentinel has to be removed if there are no other .ARM.exidx entries.
bool ARMExidxSentinelSection::empty() const {
OutputSection *OS = getParent();
+ if (!OS)
+ return false;
+
for (auto *B : OS->SectionCommands)
if (auto *ISD = dyn_cast<InputSectionDescription>(B))
for (auto *S : ISD->Sections)