[llvm-branch-commits] [llvm-branch] r339099 - Merging r338968:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 6 23:25:54 PDT 2018


Author: hans
Date: Mon Aug  6 23:25:54 2018
New Revision: 339099

URL: http://llvm.org/viewvc/llvm-project?rev=339099&view=rev
Log:
Merging r338968:
------------------------------------------------------------------------
r338968 | echristo | 2018-08-05 16:23:37 +0200 (Sun, 05 Aug 2018) | 6 lines

Revert "Add a warning if someone attempts to add extra section flags to sections"

There are a bunch of edge cases and inconsistencies in how we're emitting sections
cause this warning to fire and it needs more work.

This reverts commit r335558.
------------------------------------------------------------------------

Removed:
    llvm/branches/release_70/test/MC/ELF/extra-section-flags.s
Modified:
    llvm/branches/release_70/   (props changed)
    llvm/branches/release_70/lib/MC/MCParser/ELFAsmParser.cpp

Propchange: llvm/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  6 23:25:54 2018
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,338552,338554,338599,338658,338665,338682,338703,338709,338751,338762,338817
+/llvm/trunk:155241,338552,338554,338599,338658,338665,338682,338703,338709,338751,338762,338817,338968

Modified: llvm/branches/release_70/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/MC/MCParser/ELFAsmParser.cpp?rev=339099&r1=339098&r2=339099&view=diff
==============================================================================
--- llvm/branches/release_70/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/branches/release_70/lib/MC/MCParser/ELFAsmParser.cpp Mon Aug  6 23:25:54 2018
@@ -481,34 +481,6 @@ static bool hasPrefix(StringRef SectionN
   return SectionName.startswith(Prefix) || SectionName == Prefix.drop_back();
 }
 
-// Return a set of section flags based on the section name that can then
-// be augmented later, otherwise return 0 if we don't have any reasonable
-// defaults.
-static unsigned defaultSectionFlags(StringRef SectionName) {
-
-  if (hasPrefix(SectionName, ".rodata.cst"))
-    return ELF::SHF_ALLOC | ELF::SHF_MERGE;
-
-  if (hasPrefix(SectionName, ".rodata.") || SectionName == ".rodata1")
-    return ELF::SHF_ALLOC;
-
-  if (SectionName == ".fini" || SectionName == ".init" ||
-      hasPrefix(SectionName, ".text."))
-    return ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
-
-  if (hasPrefix(SectionName, ".data.") || SectionName == ".data1" ||
-      hasPrefix(SectionName, ".bss.") ||
-      hasPrefix(SectionName, ".init_array.") ||
-      hasPrefix(SectionName, ".fini_array.") ||
-      hasPrefix(SectionName, ".preinit_array."))
-    return ELF::SHF_ALLOC | ELF::SHF_WRITE;
-
-  if (hasPrefix(SectionName, ".tdata.") || hasPrefix(SectionName, ".tbss."))
-    return ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_TLS;
-
-  return 0;
-}
-
 bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
   StringRef SectionName;
 
@@ -518,13 +490,27 @@ bool ELFAsmParser::ParseSectionArguments
   StringRef TypeName;
   int64_t Size = 0;
   StringRef GroupName;
+  unsigned Flags = 0;
   const MCExpr *Subsection = nullptr;
   bool UseLastGroup = false;
   MCSymbolELF *Associated = nullptr;
   int64_t UniqueID = ~0;
 
-  // Set the default section flags first in case no others are given.
-  unsigned Flags = defaultSectionFlags(SectionName);
+  // Set the defaults first.
+  if (hasPrefix(SectionName, ".rodata.") || SectionName == ".rodata1")
+    Flags |= ELF::SHF_ALLOC;
+  else if (SectionName == ".fini" || SectionName == ".init" ||
+           hasPrefix(SectionName, ".text."))
+    Flags |= ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
+  else if (hasPrefix(SectionName, ".data.") || SectionName == ".data1" ||
+           hasPrefix(SectionName, ".bss.") ||
+           hasPrefix(SectionName, ".init_array.") ||
+           hasPrefix(SectionName, ".fini_array.") ||
+           hasPrefix(SectionName, ".preinit_array."))
+    Flags |= ELF::SHF_ALLOC | ELF::SHF_WRITE;
+  else if (hasPrefix(SectionName, ".tdata.") ||
+           hasPrefix(SectionName, ".tbss."))
+    Flags |= ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_TLS;
 
   if (getLexer().is(AsmToken::Comma)) {
     Lex();
@@ -552,12 +538,6 @@ bool ELFAsmParser::ParseSectionArguments
 
     if (extraFlags == -1U)
       return TokError("unknown flag");
-
-    // If we found additional section flags on a known section then give a
-    // warning.
-    if (Flags && Flags != extraFlags)
-      Warning(loc, "setting incorrect section attributes for " + SectionName);
-
     Flags |= extraFlags;
 
     bool Mergeable = Flags & ELF::SHF_MERGE;

Removed: llvm/branches/release_70/test/MC/ELF/extra-section-flags.s
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/test/MC/ELF/extra-section-flags.s?rev=339098&view=auto
==============================================================================
--- llvm/branches/release_70/test/MC/ELF/extra-section-flags.s (original)
+++ llvm/branches/release_70/test/MC/ELF/extra-section-flags.s (removed)
@@ -1,12 +0,0 @@
-# RUN: llvm-mc -triple x86_64-unknown-unknown -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s
-
-.section .rodata, "ax"
-# CHECK: warning: setting incorrect section attributes for .rodata
-nop
-
-.section .rodata, "a"
-nop
-.section .rodata.cst4, "aM", at progbits,8
-nop
-# CHECK-NOT: warning:
-




More information about the llvm-branch-commits mailing list