aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object
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
commitb35a896e072ff46c38905419b7f55aaccdb1d702 (patch)
tree704310e3e3dab82ed34832f89af0823e27a51614 /lib/Object
parent2d7ea04e2822bbe5faad0eefceb7a300ea01224e (diff)
downloadexternal_llvm-b35a896e072ff46c38905419b7f55aaccdb1d702.zip
external_llvm-b35a896e072ff46c38905419b7f55aaccdb1d702.tar.gz
external_llvm-b35a896e072ff46c38905419b7f55aaccdb1d702.tar.bz2
[Object/COFF]: Expose getSectionName.
Also add some documentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153050 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/COFFObjectFile.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp
index 22894a3..afe9e73 100644
--- a/lib/Object/COFFObjectFile.cpp
+++ b/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);
}