Index: lld/ELF/SyntheticSections.h
--- lld/ELF/SyntheticSections.h.orig
+++ lld/ELF/SyntheticSections.h
@@ -433,6 +433,11 @@ class DynamicReloc { (public)
   uint64_t getOffset() const;
   uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
   bool needsDynSymIndex() const { return isAgainstSymbol; }
+  void convertToRelative(RelType relativeRel) {
+    type = relativeRel;
+    isAgainstSymbol = false;
+    expr = R_ABS;
+  }
 
   /// Computes the addend of the dynamic relocation. Note that this is not the
   /// same as the #addend member variable as it may also include the symbol
@@ -661,6 +666,7 @@ class SymbolTableBaseSection : public SyntheticSection
   void finalizeContents() override;
   size_t getSize() const override { return getNumSymbols() * entsize; }
   void addSymbol(Symbol *sym);
+  void addLocalSectionSymbol(Symbol *sym);
   unsigned getNumSymbols() const { return symbols.size() + 1; }
   size_t getSymbolIndex(const Symbol &sym);
   ArrayRef<SymbolTableEntry> getSymbols() const { return symbols; }
@@ -670,6 +676,7 @@ class SymbolTableBaseSection : public SyntheticSection
 
   // A vector of symbols and their string table offsets.
   SmallVector<SymbolTableEntry, 0> symbols;
+  size_t numLocalDynamicSymbols = 0;
 
   StringTableSection &strTabSec;
 
@@ -1462,7 +1469,11 @@ void addVerneed(Ctx &, Symbol &ss);
 // placed in it.
 struct PhdrEntry {
   PhdrEntry(Ctx &ctx, unsigned type, unsigned flags)
+#ifdef __OpenBSD__
+      : p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.textAlignPageSize : 0),
+#else
       : p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.maxPageSize : 0),
+#endif
         p_type(type), p_flags(flags) {}
   void add(OutputSection *sec);
 
