summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-05-27 20:25:06 +0000
committerNick Kledzik <kledzik@apple.com>2014-05-27 20:25:06 +0000
commit3e90e5f1874103a0a516f14ee8d226b2c6265446 (patch)
treed78eda62c2faaabb5f6245f85fcbd19f318f7b73 /lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
parent6900674aafbe03e7194e00bf12a5f888de03a2d5 (diff)
downloadbcm5719-llvm-3e90e5f1874103a0a516f14ee8d226b2c6265446.tar.gz
bcm5719-llvm-3e90e5f1874103a0a516f14ee8d226b2c6265446.zip
[mach-o] Add support for reading utf16 string literal sections
llvm-svn: 209684
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp')
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 596a8fe39d9..7564748c94b 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -113,6 +113,23 @@ static error_code processSection(MachOFile &file, const Section &section,
unsigned offset = 0;
switch (section.type) {
case llvm::MachO::S_REGULAR:
+ if (section.segmentName.equals("__TEXT") &&
+ section.sectionName.equals("__ustring")) {
+ if ((section.content.size() % 4) != 0)
+ return make_dynamic_error_code(Twine("Section ") + section.segmentName
+ + "/" + section.sectionName
+ + " has a size that is not even");
+ for (size_t i = 0, e = section.content.size(); i != e; i +=2) {
+ if ((section.content[i] == 0) && (section.content[i+1] == 0)) {
+ unsigned size = i - offset + 2;
+ ArrayRef<uint8_t> utf16Content = section.content.slice(offset, size);
+ file.addDefinedAtom(StringRef(), DefinedAtom::scopeLinkageUnit,
+ DefinedAtom::typeUTF16String, utf16Content,
+ copyRefs);
+ offset = i + 2;
+ }
+ }
+ }
case llvm::MachO::S_COALESCED:
case llvm::MachO::S_ZEROFILL:
// These sections are broken in to atoms based on symbols.
OpenPOWER on IntegriCloud