Index: lld/ELF/InputFiles.cpp
--- lld/ELF/InputFiles.cpp.orig
+++ lld/ELF/InputFiles.cpp
@@ -47,6 +47,8 @@ extern template void ObjFile<ELF32BE>::importCmseSymbo
 extern template void ObjFile<ELF64LE>::importCmseSymbols();
 extern template void ObjFile<ELF64BE>::importCmseSymbols();
 
+DenseMap<StringRef, StringRef> elf::gnuWarnings;
+
 // Returns "<internal>", "foo.a(bar.o)" or "baz.o".
 std::string elf::toStr(Ctx &ctx, const InputFile *f) {
   static std::mutex mu;
@@ -70,6 +72,19 @@ const ELFSyncStream &elf::operator<<(const ELFSyncStre
   return s << toStr(s.ctx, f);
 }
 
+// .gnu.warning.SYMBOL are treated as warning symbols for the given symbol
+void InputFile::parseGNUWarning(Ctx &ctx, StringRef name, ArrayRef<char> data, size_t size) {
+  static std::mutex mu;
+  if (!name.empty() && name.starts_with(".gnu.warning.")) {
+    std::lock_guard<std::mutex> lock(mu);
+    StringRef wsym = name.substr(13);
+    StringRef s(data.begin());
+    StringRef wng(s.substr(0, size));
+    ctx.symtab->insert(wsym)->gwarn = true;
+    gnuWarnings.insert({wsym, wng});
+  }
+}
+
 static ELFKind getELFKind(Ctx &ctx, MemoryBufferRef mb, StringRef archiveName) {
   unsigned char size;
   unsigned char endian;
@@ -808,6 +823,12 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComd
     case SHT_PREINIT_ARRAY:
       this->sections[i] =
           createInputSection(i, sec, check(obj.getSectionName(sec, shstrtab)));
+      if (type == SHT_PROGBITS) {
+        StringRef name = check(obj.getSectionName(sec, shstrtab));
+        ArrayRef<char> data =
+            CHECK2(obj.template getSectionContentsAsArray<char>(sec), this);
+	parseGNUWarning(ctx, name, data, sec.sh_size);
+      }
       break;
     case SHT_LLVM_LTO:
       // Discard .llvm.lto in a relocatable link that does not use the bitcode.
@@ -1510,6 +1531,9 @@ template <class ELFT> void SharedFile::parse() {
   const ELFFile<ELFT> obj = this->getObj<ELFT>();
   ArrayRef<Elf_Shdr> sections = getELFShdrs<ELFT>();
 
+  StringRef sectionStringTable =
+      CHECK2(obj.getSectionStringTable(sections), this);
+
   const Elf_Shdr *versymSec = nullptr;
   const Elf_Shdr *verdefSec = nullptr;
   const Elf_Shdr *verneedSec = nullptr;
@@ -1533,6 +1557,13 @@ template <class ELFT> void SharedFile::parse() {
     case SHT_GNU_verneed:
       verneedSec = &sec;
       break;
+    case SHT_PROGBITS: {
+      StringRef name = CHECK2(obj.getSectionName(sec, sectionStringTable), this);
+      ArrayRef<char> data =
+          CHECK2(obj.template getSectionContentsAsArray<char>(sec), this);
+      parseGNUWarning(ctx, name, data, sec.sh_size);
+      break;
+    }
     }
   }
 
