diff options
| author | Joey Gouly <joey.gouly@gmail.com> | 2014-01-13 22:28:02 +0000 |
|---|---|---|
| committer | Joey Gouly <joey.gouly@gmail.com> | 2014-01-13 22:28:02 +0000 |
| commit | d2215375a8b3442639f3fe09043acf6b68105340 (patch) | |
| tree | 6ed88409c0792c923cc6bf1f70dc328faa130fe0 /lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp | |
| parent | 4c73e594753f496e85159afdcb1c6323391c6d4b (diff) | |
| download | bcm5719-llvm-d2215375a8b3442639f3fe09043acf6b68105340.tar.gz bcm5719-llvm-d2215375a8b3442639f3fe09043acf6b68105340.zip | |
[MachO] Add basic support for local symbols.
llvm-svn: 199155
Diffstat (limited to 'lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp')
| -rw-r--r-- | lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp index 2a46e36e8c0..66642deaef2 100644 --- a/lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp +++ b/lld/unittests/MachOTests/MachONormalizedFileToAtomsTests.cpp @@ -33,38 +33,56 @@ TEST(ToAtomsTest, basic_obj_x86_64) { NormalizedFile f; f.arch = lld::MachOLinkingContext::arch_x86_64; Section textSection; - static const uint8_t contentBytes[] = { 0x90, 0xC3, 0xC3 }; + static const uint8_t contentBytes[] = { 0x90, 0xC3, 0xC3, 0xC4 }; const unsigned contentSize = sizeof(contentBytes) / sizeof(contentBytes[0]); textSection.content = llvm::makeArrayRef(contentBytes, contentSize); f.sections.push_back(textSection); Symbol fooSymbol; fooSymbol.name = "_foo"; fooSymbol.type = N_SECT; + fooSymbol.scope = N_EXT; fooSymbol.sect = 1; fooSymbol.value = 0; f.globalSymbols.push_back(fooSymbol); Symbol barSymbol; barSymbol.name = "_bar"; barSymbol.type = N_SECT; + barSymbol.scope = N_EXT; barSymbol.sect = 1; barSymbol.value = 2; f.globalSymbols.push_back(barSymbol); + Symbol bazSymbol; + bazSymbol.name = "_baz"; + bazSymbol.type = N_SECT; + bazSymbol.scope = N_EXT | N_PEXT; + bazSymbol.sect = 1; + bazSymbol.value = 3; + f.localSymbols.push_back(bazSymbol); ErrorOr<std::unique_ptr<const lld::File>> atom_f = normalizedToAtoms(f, "", false); EXPECT_FALSE(!atom_f); const lld::File &file = **atom_f; - EXPECT_EQ(2U, file.defined().size()); + EXPECT_EQ(3U, file.defined().size()); lld::File::defined_iterator it = file.defined().begin(); const lld::DefinedAtom *atom1 = *it; ++it; const lld::DefinedAtom *atom2 = *it; + ++it; + const lld::DefinedAtom *atom3 = *it; EXPECT_TRUE(atom1->name().equals("_foo")); EXPECT_EQ(2U, atom1->rawContent().size()); EXPECT_EQ(0x90, atom1->rawContent()[0]); EXPECT_EQ(0xC3, atom1->rawContent()[1]); + EXPECT_EQ(lld::Atom::scopeGlobal, atom1->scope()); EXPECT_TRUE(atom2->name().equals("_bar")); EXPECT_EQ(1U, atom2->rawContent().size()); EXPECT_EQ(0xC3, atom2->rawContent()[0]); + EXPECT_EQ(lld::Atom::scopeGlobal, atom2->scope()); + + EXPECT_TRUE(atom3->name().equals("_baz")); + EXPECT_EQ(1U, atom3->rawContent().size()); + EXPECT_EQ(0xC4, atom3->rawContent()[0]); + EXPECT_EQ(lld::Atom::scopeLinkageUnit, atom3->scope()); } |

