summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-03-19 20:27:15 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-03-19 20:27:15 +0000
commit53c2d5477adca4f6ed991ec9e4cbc26445c58a7b (patch)
tree0ec4c84e0f59a9c5779c73838350b78841d3ef88 /llvm/lib/Object/COFFObjectFile.cpp
parent3edd854d64fc4899404c42aaff76527b780608d5 (diff)
downloadbcm5719-llvm-53c2d5477adca4f6ed991ec9e4cbc26445c58a7b.tar.gz
bcm5719-llvm-53c2d5477adca4f6ed991ec9e4cbc26445c58a7b.zip
[Object/COFF]: Expose getSectionName.
Also add some documentation. llvm-svn: 153050
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 22894a348cf..afe9e737f0e 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -300,25 +300,7 @@ error_code COFFObjectFile::getSectionNext(DataRefImpl Sec,
error_code COFFObjectFile::getSectionName(DataRefImpl Sec,
StringRef &Result) const {
const coff_section *sec = toSec(Sec);
- StringRef name;
- if (sec->Name[7] == 0)
- // Null terminated, let ::strlen figure out the length.
- name = sec->Name;
- else
- // Not null terminated, use all 8 bytes.
- name = StringRef(sec->Name, 8);
-
- // Check for string table entry. First byte is '/'.
- if (name[0] == '/') {
- uint32_t Offset;
- if (name.substr(1).getAsInteger(10, Offset))
- return object_error::parse_failed;
- if (error_code ec = getString(Offset, name))
- return ec;
- }
-
- Result = name;
- return object_error::success;
+ return getSectionName(sec, Result);
}
error_code COFFObjectFile::getSectionAddress(DataRefImpl Sec,
@@ -631,6 +613,29 @@ error_code COFFObjectFile::getSymbolName(const coff_symbol *symbol,
return object_error::success;
}
+error_code COFFObjectFile::getSectionName(const coff_section *Sec,
+ StringRef &Res) const {
+ StringRef Name;
+ if (Sec->Name[7] == 0)
+ // Null terminated, let ::strlen figure out the length.
+ Name = Sec->Name;
+ else
+ // Not null terminated, use all 8 bytes.
+ Name = StringRef(Sec->Name, 8);
+
+ // Check for string table entry. First byte is '/'.
+ if (Name[0] == '/') {
+ uint32_t Offset;
+ if (Name.substr(1).getAsInteger(10, Offset))
+ return object_error::parse_failed;
+ if (error_code ec = getString(Offset, Name))
+ return ec;
+ }
+
+ Res = Name;
+ return object_error::success;
+}
+
const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel) const {
return reinterpret_cast<const coff_relocation*>(Rel.p);
}
OpenPOWER on IntegriCloud