Add absolute symbol scope recognition in lld/Core

llvm-svn: 167394
This commit is contained in:
Hemant Kulkarni 2012-11-05 19:13:54 +00:00
parent 77ed89dbad
commit f828613945
3 changed files with 36 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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: ...