diff options
author | Hemant Kulkarni <khemant@codeaurora.org> | 2012-11-05 19:13:54 +0000 |
---|---|---|
committer | Hemant Kulkarni <khemant@codeaurora.org> | 2012-11-05 19:13:54 +0000 |
commit | f82861394575eb95586884ec0f8907a4126d5c6a (patch) | |
tree | ae98b8ef4db14951e3b1617738f1c39b5d4e54c3 /lld | |
parent | 77ed89dbad943d657dcc79fa29f92fe6abd74efc (diff) | |
download | bcm5719-llvm-f82861394575eb95586884ec0f8907a4126d5c6a.tar.gz bcm5719-llvm-f82861394575eb95586884ec0f8907a4126d5c6a.zip |
Add absolute symbol scope recognition in lld/Core
llvm-svn: 167394
Diffstat (limited to 'lld')
-rw-r--r-- | lld/lib/Core/Resolver.cpp | 4 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/YAML/ReaderYAML.cpp | 12 | ||||
-rw-r--r-- | lld/test/absolute-local.objtxt | 26 |
3 files changed, 36 insertions, 6 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 018cb0a658d..8b426fae87f 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -151,7 +151,9 @@ void Resolver::doAbsoluteAtom(const AbsoluteAtom& atom) { _atoms.push_back(&atom); // tell symbol table - _symbolTable.add(atom); + if (atom.scope() != Atom::scopeTranslationUnit) { + _symbolTable.add(atom); + } } diff --git a/lld/lib/ReaderWriter/YAML/ReaderYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderYAML.cpp index bf8e70c1985..bb0a2726f89 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderYAML.cpp @@ -419,10 +419,11 @@ private: /// class YAMLAbsoluteAtom : public AbsoluteAtom { public: - YAMLAbsoluteAtom(YAMLFile &f, int32_t, StringRef name, uint64_t v) + YAMLAbsoluteAtom(YAMLFile &f, int32_t, StringRef name, uint64_t v, Atom::Scope scope) : _file(f) , _name(name) - , _value(v) { + , _value(v) + , _scope(scope){ } virtual const class File &file() const { @@ -430,7 +431,7 @@ public: } virtual Scope scope() const { - return scopeGlobal; + return _scope; } virtual StringRef name() const { @@ -445,6 +446,7 @@ private: YAMLFile &_file; StringRef _name; uint64_t _value; + Atom::Scope _scope; }; @@ -779,7 +781,8 @@ void YAMLState::makeAbsoluteAtom(Node *node) { + "' has attributes only allowed on shared library atoms"); _error = make_error_code(yaml_reader_error::illegal_value); } - AbsoluteAtom *a = new YAMLAbsoluteAtom(*_file, _ordinal, _name, _value); + AbsoluteAtom *a = new YAMLAbsoluteAtom(*_file, _ordinal, _name, _value, + _scope); _file->addAbsoluteAtom(a); } @@ -939,7 +942,6 @@ void YAMLState::parseAtomScope(ScalarNode *node) { _stream->printError(node, "Invalid value for 'scope:'"); _error = make_error_code(yaml_reader_error::illegal_value); } - _hasDefinedAtomAttributes = true; } void YAMLState::parseAtomDefinition(ScalarNode *node) { diff --git a/lld/test/absolute-local.objtxt b/lld/test/absolute-local.objtxt new file mode 100644 index 00000000000..0db54e5df7e --- /dev/null +++ b/lld/test/absolute-local.objtxt @@ -0,0 +1,26 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that absolute symbols with local scope do not cause name conflict +# +--- +atoms: + - name: putchar + definition: absolute + value: 0xFFFF0040 + scope: static + + - name: putchar + definition: absolute + value: 0xFFFF0040 + scope: static +... + +# CHECK: --- +# CHECK: - name: putchar +# CHECK: definition: absolute +# CHECK: value: 0xffff0040 +# CHECK: - name: putchar +# CHECK: definition: absolute +# CHECK: value: 0xffff0040 +# CHECK: ... |