[lld] r205224 - Revert "[core] support .gnu.linkonce sections"
Shankar Easwaran
shankarke at gmail.com
Mon Mar 31 10:12:06 PDT 2014
Author: shankare
Date: Mon Mar 31 12:12:06 2014
New Revision: 205224
URL: http://llvm.org/viewvc/llvm-project?rev=205224&view=rev
Log:
Revert "[core] support .gnu.linkonce sections"
This reverts commit 5d5ca72a7876c3dd3dd1db83dc6a0d74be9e2cd1.
Discuss on a better design to raise error when there is a similar group with Gnu
linkonce sections and COMDAT sections.
Removed:
lld/trunk/test/core/gnulinkonce-rearrange-resolve.objtxt
lld/trunk/test/core/gnulinkonce-remaining-undef.objtxt
lld/trunk/test/core/gnulinkonce-resolve.objtxt
lld/trunk/test/core/gnulinkonce-simple.objtxt
lld/trunk/test/core/sectiongroup-gnulinkonce-error.objtxt
Modified:
lld/trunk/include/lld/Core/DefinedAtom.h
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/lib/Core/DefinedAtom.cpp
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Mon Mar 31 12:12:06 2014
@@ -147,7 +147,6 @@ public:
typeRWNote, // Identifies readwrite note sections [ELF]
typeNoAlloc, // Identifies non allocatable sections [ELF]
typeGroupComdat, // Identifies a section group [ELF, COFF]
- typeGnuLinkOnce, // Identifies a gnu.linkonce section [ELF]
};
// Permission bits for atoms and segments. The order of these values are
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Mon Mar 31 12:12:06 2014
@@ -67,8 +67,8 @@ public:
private:
typedef std::function<void(StringRef, bool)> UndefCallback;
- /// \brief Add section group/.gnu.linkonce if it does not exist previously.
- bool maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);
+ /// \brief Add section group if it does not exist previously.
+ void maybeAddSectionGroup(const DefinedAtom &atom);
/// \brief The main function that iterates over the files to resolve
bool resolveUndefines();
Modified: lld/trunk/lib/Core/DefinedAtom.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/lib/Core/DefinedAtom.cpp (original)
+++ lld/trunk/lib/Core/DefinedAtom.cpp Mon Mar 31 12:12:06 2014
@@ -72,7 +72,6 @@ DefinedAtom::ContentPermissions DefinedA
return permRW_L;
case typeGroupComdat:
- case typeGnuLinkOnce:
case typeUnknown:
case typeTempLTO:
return permUnknown;
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Mon Mar 31 12:12:06 2014
@@ -184,22 +184,11 @@ void Resolver::doUndefinedAtom(const Und
}
/// \brief Add the section group and the group-child reference members.
-bool Resolver::maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom) {
+void Resolver::maybeAddSectionGroup(const DefinedAtom &atom) {
// First time adding a group ?
bool isFirstTime = _symbolTable.addGroup(atom);
-
- if (!isFirstTime) {
- // If duplicate symbols are allowed, select the first group.
- if (_context.getAllowDuplicates())
- return true;
- const DefinedAtom *prevGroup = llvm::dyn_cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
- assert(prevGroup && "Internal Error: The group atom could only be a defined atom");
- // The atoms should be of the same content type, reject invalid group
- // resolution behaviors.
- if (atom.contentType() != prevGroup->contentType())
- return false;
- return true;
- }
+ if (!isFirstTime)
+ return;
for (const Reference *r : atom) {
if ((r->kindNamespace() == lld::Reference::KindNamespace::all) &&
@@ -211,7 +200,6 @@ bool Resolver::maybeAddSectionGroupOrGnu
_symbolTable.add(*target);
}
}
- return true;
}
// called on each atom when a file is added
@@ -241,14 +229,8 @@ void Resolver::doDefinedAtom(const Defin
// add to list of known atoms
_atoms.push_back(&atom);
- if ((atom.contentType() == DefinedAtom::typeGroupComdat) ||
- (atom.contentType() == DefinedAtom::typeGnuLinkOnce)) {
- // Raise error if there exists a similar gnu linkonce section.
- if (!maybeAddSectionGroupOrGnuLinkOnce(atom)) {
- llvm::errs() << "SymbolTable: error while merging " << atom.name() << "\n";
- llvm::report_fatal_error("duplicate symbol error");
- }
- }
+ if (atom.contentType() == DefinedAtom::typeGroupComdat)
+ maybeAddSectionGroup(atom);
else
_symbolTable.add(atom);
Modified: lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp Mon Mar 31 12:12:06 2014
@@ -41,8 +41,7 @@ public:
// We are trying to process all atoms, but the defined() iterator does not
// return group children. So, when a group parent is found, we need to
// handle each child atom.
- if (defAtom->contentType() == DefinedAtom::typeGroupComdat ||
- defAtom->contentType() == DefinedAtom::typeGnuLinkOnce) {
+ if (defAtom->contentType() == DefinedAtom::typeGroupComdat) {
for (const Reference *r : *defAtom) {
if (r->kindNamespace() != lld::Reference::KindNamespace::all)
continue;
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=205224&r1=205223&r2=205224&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Mon Mar 31 12:12:06 2014
@@ -71,9 +71,7 @@ public:
if (!atom->name().empty())
buildDuplicateNameMap(*atom);
- if (atom->contentType() == DefinedAtom::typeGroupComdat ||
- atom->contentType() == DefinedAtom::typeGnuLinkOnce) {
-
+ if (atom->contentType() == DefinedAtom::typeGroupComdat) {
for (const lld::Reference *ref : *atom) {
if (ref->kindNamespace() != lld::Reference::KindNamespace::all)
continue;
@@ -231,8 +229,7 @@ private:
}
if (const lld::DefinedAtom *da = dyn_cast<DefinedAtom>(atom)) {
- if (da->contentType() == DefinedAtom::typeGroupComdat ||
- da->contentType() == DefinedAtom::typeGnuLinkOnce) {
+ if (da->contentType() == DefinedAtom::typeGroupComdat) {
if (_groupMap.count(name)) {
_io.setError(Twine("duplicate group name: ") + name);
} else {
@@ -479,8 +476,7 @@ template <> struct ScalarEnumerationTrai
io.enumCase(value, "ro-note", DefinedAtom::typeRONote);
io.enumCase(value, "rw-note", DefinedAtom::typeRWNote);
io.enumCase(value, "no-alloc", DefinedAtom::typeNoAlloc);
- io.enumCase(value, "group-comdat", DefinedAtom::typeGroupComdat);
- io.enumCase(value, "gnu-linkonce", DefinedAtom::typeGnuLinkOnce);
+ io.enumCase(value, "group-comdat", DefinedAtom::typeGroupComdat);
}
};
Removed: lld/trunk/test/core/gnulinkonce-rearrange-resolve.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/gnulinkonce-rearrange-resolve.objtxt?rev=205223&view=auto
==============================================================================
--- lld/trunk/test/core/gnulinkonce-rearrange-resolve.objtxt (original)
+++ lld/trunk/test/core/gnulinkonce-rearrange-resolve.objtxt (removed)
@@ -1,115 +0,0 @@
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that gnu linkonce sections are parsed and the first section selected for symbol
-# resolution
-#
-
----
-defined-atoms:
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
----
-defined-atoms:
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
-...
-
-# CHECK: defined-atoms:
-# CHECK: - name: g1
-# CHECK: ref-name: [[PARENT:[a-zA-Z\.0-9_]+]]
-# CHECK: type: gnu-linkonce
-# CHECK: references:
-# CHECK: - kind: group-child
-# CHECK: target: f1
-# CHECK: - kind: group-child
-# CHECK: target: f2
-# CHECK: - kind: group-child
-# CHECK: target: [[CHILD:[a-zA-Z\.0-9_]+]]
-# CHECK: - kind: group-child
-# CHECK: target: d1
-# CHECK: - name: f1
-# CHECK: references:
-# CHECK: - kind: group-parent
-# CHECK: target: [[PARENT]]
-# CHECK: - name: f2
-# CHECK: references:
-# CHECK: - kind: group-parent
-# CHECK: target: [[PARENT]]
-# CHECK: - name: g1
-# CHECK: ref-name: [[CHILD]]
-# CHECK: references:
-# CHECK: - kind: group-parent
-# CHECK: target: [[PARENT]]
-# CHECK: - name: d1
-# CHECK: references:
-# CHECK: - kind: group-parent
-# CHECK: target: [[PARENT]]
Removed: lld/trunk/test/core/gnulinkonce-remaining-undef.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/gnulinkonce-remaining-undef.objtxt?rev=205223&view=auto
==============================================================================
--- lld/trunk/test/core/gnulinkonce-remaining-undef.objtxt (original)
+++ lld/trunk/test/core/gnulinkonce-remaining-undef.objtxt (removed)
@@ -1,113 +0,0 @@
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that gnu linkonce sections are parsed and the first section selected for
-# symbol resolution. The second file which has the same gnu linkonce section has
-# a unresolved undefined symbol. lets make sure that the symbol is kept around
-# in the final link and remains undefined.
-#
-
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
----
-defined-atoms:
- - name: anotherfunction
- scope: global
- type: data
- references:
- - kind: layout-before
- target: f3
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f3
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: f3
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
-undefined-atoms:
- - name: f3
- can-be-null: never
-...
-
-#CHECK: - name: anotherfunction
-#CHECK: scope: global
-#CHECK: type: data
-#CHECK: references:
-#CHECK: - kind: layout-before
-#CHECK: offset: 0
-#CHECK: target: f3
-#CHECK: undefined-atoms:
-#CHECK: - name: f3
Removed: lld/trunk/test/core/gnulinkonce-resolve.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/gnulinkonce-resolve.objtxt?rev=205223&view=auto
==============================================================================
--- lld/trunk/test/core/gnulinkonce-resolve.objtxt (original)
+++ lld/trunk/test/core/gnulinkonce-resolve.objtxt (removed)
@@ -1,133 +0,0 @@
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that gnu linkonce sections are parsed and the first section selected for symbol
-# resolution
-#
-
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
-...
-
-#CHECK: defined-atoms:
-#CHECK: - name: g1
-#CHECK: ref-name: [[PARENT:[a-zA-Z\.0-9_]+]]
-#CHECK: scope: global
-#CHECK: type: gnu-linkonce
-#CHECK: references:
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDONE:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDTWO:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDTHREE:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDFOUR:[a-zA-Z\.0-9_]+]]
-#CHECK: - name: f1
-#CHECK: ref-name: [[GCHILDONE]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: f2
-#CHECK: ref-name: [[GCHILDTWO]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: g1
-#CHECK: ref-name: [[GCHILDTHREE]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: d1
-#CHECK: ref-name: [[GCHILDFOUR]]
-#CHECK: scope: global
-#CHECK: type: data
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: ...
Removed: lld/trunk/test/core/gnulinkonce-simple.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/gnulinkonce-simple.objtxt?rev=205223&view=auto
==============================================================================
--- lld/trunk/test/core/gnulinkonce-simple.objtxt (original)
+++ lld/trunk/test/core/gnulinkonce-simple.objtxt (removed)
@@ -1,112 +0,0 @@
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that gnu linkonce sections are parsed properly when there is a reference to a
-# atom from outside the gnu linkonce section.
-#
-
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: d1
- - kind: group-child
- target: g1
- - name: anotherfunction
- scope: global
- type: data
- references:
- - kind: layout-before
- target: f1
-
-undefined-atoms:
- - name: f1
- can-be-null: never
-...
-
-#CHECK: defined-atoms:
-#CHECK: - name: g1
-#CHECK: ref-name: [[PARENT:[a-zA-Z\.0-9_]+]]
-#CHECK: scope: global
-#CHECK: type: gnu-linkonce
-#CHECK: references:
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDONE:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDTWO:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDTHREE:[a-zA-Z\.0-9_]+]]
-#CHECK: - kind: group-child
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDFOUR:[a-zA-Z\.0-9_]+]]
-#CHECK: - name: f1
-#CHECK: ref-name: [[GCHILDONE]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: f2
-#CHECK: ref-name: [[GCHILDTWO]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: d1
-#CHECK: ref-name: [[GCHILDTHREE]]
-#CHECK: scope: global
-#CHECK: type: data
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: g1
-#CHECK: ref-name: [[GCHILDFOUR]]
-#CHECK: scope: global
-#CHECK: references:
-#CHECK: - kind: group-parent
-#CHECK: offset: 0
-#CHECK: target: [[PARENT]]
-#CHECK: - name: anotherfunction
-#CHECK: scope: global
-#CHECK: type: data
-#CHECK: references:
-#CHECK: - kind: layout-before
-#CHECK: offset: 0
-#CHECK: target: [[GCHILDONE]]
-#CHECK: ...
Removed: lld/trunk/test/core/sectiongroup-gnulinkonce-error.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/sectiongroup-gnulinkonce-error.objtxt?rev=205223&view=auto
==============================================================================
--- lld/trunk/test/core/sectiongroup-gnulinkonce-error.objtxt (original)
+++ lld/trunk/test/core/sectiongroup-gnulinkonce-error.objtxt (removed)
@@ -1,88 +0,0 @@
-# RUN: not lld -core %s 2>&1 | FileCheck %s
-
-#
-# Test that section groups/gnu linkonce sections are parsed and a merge error
-# is displayed at the time of symbol resolution.
-#
-
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: group-comdat
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
----
-defined-atoms:
- - name: f1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: f2
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: code
- references:
- - kind: group-parent
- target: g1
- - name: d1
- scope: global
- type: data
- references:
- - kind: group-parent
- target: g1
- - name: g1
- scope: global
- type: gnu-linkonce
- references:
- - kind: group-child
- target: f1
- - kind: group-child
- target: f2
- - kind: group-child
- target: g1
- - kind: group-child
- target: d1
-...
-
-#CHECK: SymbolTable: error while merging g1
-#CHECK: LLVM ERROR: duplicate symbol error
-
More information about the llvm-commits
mailing list