[lld] r199066 - Factor the symbol handling in normalizedToAtoms into a separate function.

Joey Gouly joey.gouly at gmail.com
Sun Jan 12 14:55:49 PST 2014


Author: joey
Date: Sun Jan 12 16:55:49 2014
New Revision: 199066

URL: http://llvm.org/viewvc/llvm-project?rev=199066&view=rev
Log:
Factor the symbol handling in normalizedToAtoms into a separate function.

No functionality change.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=199066&r1=199065&r2=199066&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Sun Jan 12 16:55:49 2014
@@ -53,19 +53,24 @@ static uint64_t nextSymbolAddress(const
   return closestAddr;
 }
 
+static void processSymbol(const NormalizedFile &normalizedFile, MachOFile &file,
+                          const Symbol &sym, bool copyRefs) {
+  // Mach-O symbol table does have size in it, so need to scan ahead
+  // to find symbol with next highest address.
+  const Section &section = normalizedFile.sections[sym.sect - 1];
+  uint64_t offset = sym.value - section.address;
+  uint64_t size = nextSymbolAddress(normalizedFile, sym) - sym.value;
+  ArrayRef<uint8_t> atomContent = section.content.slice(offset, size);
+  file.addDefinedAtom(sym.name, atomContent, copyRefs);
+}
+
 static ErrorOr<std::unique_ptr<lld::File>>
 normalizedObjectToAtoms(const NormalizedFile &normalizedFile, StringRef path,
                         bool copyRefs) {
   std::unique_ptr<MachOFile> file(new MachOFile(path));
 
   for (const Symbol &sym : normalizedFile.globalSymbols) {
-    // Mach-O symbol table does have size in it, so need to scan ahead
-    // to find symbol with next highest address.
-    const Section &section = normalizedFile.sections[sym.sect - 1];
-    uint64_t offset = sym.value - section.address;
-    uint64_t size = nextSymbolAddress(normalizedFile, sym) - sym.value;
-    ArrayRef<uint8_t> atomContent = section.content.slice(offset, size);
-    file->addDefinedAtom(sym.name, atomContent, copyRefs);
+    processSymbol(normalizedFile, *file, sym, copyRefs);
   }
 
   assert(normalizedFile.localSymbols.empty() &&





More information about the llvm-commits mailing list