[lld] r213362 - swapStruct extracted into include/llvm/Support/MachO.h (no functional change)
Artyom Skrobov
Artyom.Skrobov at arm.com
Fri Jul 18 02:28:11 PDT 2014
Author: askrobov
Date: Fri Jul 18 04:28:10 2014
New Revision: 213362
URL: http://llvm.org/viewvc/llvm-project?rev=213362&view=rev
Log:
swapStruct extracted into include/llvm/Support/MachO.h (no functional change)
Modified:
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h?rev=213362&r1=213361&r2=213362&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h Fri Jul 18 04:28:10 2014
@@ -25,163 +25,8 @@ namespace lld {
namespace mach_o {
namespace normalized {
-using llvm::sys::swapByteOrder;
using llvm::sys::getSwappedBytes;
-inline void swapStruct(llvm::MachO::mach_header &mh) {
- swapByteOrder(mh.magic);
- swapByteOrder(mh.cputype);
- swapByteOrder(mh.cpusubtype);
- swapByteOrder(mh.filetype);
- swapByteOrder(mh.ncmds);
- swapByteOrder(mh.sizeofcmds);
- swapByteOrder(mh.flags);
-}
-
-inline void swapStruct(llvm::MachO::load_command &lc) {
- swapByteOrder(lc.cmd);
- swapByteOrder(lc.cmdsize);
-}
-
-inline void swapStruct(llvm::MachO::symtab_command &lc) {
- swapByteOrder(lc.cmd);
- swapByteOrder(lc.cmdsize);
- swapByteOrder(lc.symoff);
- swapByteOrder(lc.nsyms);
- swapByteOrder(lc.stroff);
- swapByteOrder(lc.strsize);
-}
-
-inline void swapStruct(llvm::MachO::segment_command_64 &seg) {
- swapByteOrder(seg.cmd);
- swapByteOrder(seg.cmdsize);
- swapByteOrder(seg.vmaddr);
- swapByteOrder(seg.vmsize);
- swapByteOrder(seg.fileoff);
- swapByteOrder(seg.filesize);
- swapByteOrder(seg.maxprot);
- swapByteOrder(seg.initprot);
- swapByteOrder(seg.nsects);
- swapByteOrder(seg.flags);
-}
-
-inline void swapStruct(llvm::MachO::segment_command &seg) {
- swapByteOrder(seg.cmd);
- swapByteOrder(seg.cmdsize);
- swapByteOrder(seg.vmaddr);
- swapByteOrder(seg.vmsize);
- swapByteOrder(seg.fileoff);
- swapByteOrder(seg.filesize);
- swapByteOrder(seg.maxprot);
- swapByteOrder(seg.initprot);
- swapByteOrder(seg.nsects);
- swapByteOrder(seg.flags);
-}
-
-inline void swapStruct(llvm::MachO::section_64 §) {
- swapByteOrder(sect.addr);
- swapByteOrder(sect.size);
- swapByteOrder(sect.offset);
- swapByteOrder(sect.align);
- swapByteOrder(sect.reloff);
- swapByteOrder(sect.nreloc);
- swapByteOrder(sect.flags);
- swapByteOrder(sect.reserved1);
- swapByteOrder(sect.reserved2);
-}
-
-inline void swapStruct(llvm::MachO::section §) {
- swapByteOrder(sect.addr);
- swapByteOrder(sect.size);
- swapByteOrder(sect.offset);
- swapByteOrder(sect.align);
- swapByteOrder(sect.reloff);
- swapByteOrder(sect.nreloc);
- swapByteOrder(sect.flags);
- swapByteOrder(sect.reserved1);
- swapByteOrder(sect.reserved2);
-}
-
-inline void swapStruct(llvm::MachO::dyld_info_command &info) {
- swapByteOrder(info.cmd);
- swapByteOrder(info.cmdsize);
- swapByteOrder(info.rebase_off);
- swapByteOrder(info.rebase_size);
- swapByteOrder(info.bind_off);
- swapByteOrder(info.bind_size);
- swapByteOrder(info.weak_bind_off);
- swapByteOrder(info.weak_bind_size);
- swapByteOrder(info.lazy_bind_off);
- swapByteOrder(info.lazy_bind_size);
- swapByteOrder(info.export_off);
- swapByteOrder(info.export_size);
-}
-
-inline void swapStruct(llvm::MachO::dylib_command &d) {
- swapByteOrder(d.cmd);
- swapByteOrder(d.cmdsize);
- swapByteOrder(d.dylib.name);
- swapByteOrder(d.dylib.timestamp);
- swapByteOrder(d.dylib.current_version);
- swapByteOrder(d.dylib.compatibility_version);
-}
-
-inline void swapStruct(llvm::MachO::dylinker_command &d) {
- swapByteOrder(d.cmd);
- swapByteOrder(d.cmdsize);
- swapByteOrder(d.name);
-}
-
-inline void swapStruct(llvm::MachO::entry_point_command &e) {
- swapByteOrder(e.cmd);
- swapByteOrder(e.cmdsize);
- swapByteOrder(e.entryoff);
- swapByteOrder(e.stacksize);
-}
-
-inline void swapStruct(llvm::MachO::dysymtab_command &dst) {
- swapByteOrder(dst.cmd);
- swapByteOrder(dst.cmdsize);
- swapByteOrder(dst.ilocalsym);
- swapByteOrder(dst.nlocalsym);
- swapByteOrder(dst.iextdefsym);
- swapByteOrder(dst.nextdefsym);
- swapByteOrder(dst.iundefsym);
- swapByteOrder(dst.nundefsym);
- swapByteOrder(dst.tocoff);
- swapByteOrder(dst.ntoc);
- swapByteOrder(dst.modtaboff);
- swapByteOrder(dst.nmodtab);
- swapByteOrder(dst.extrefsymoff);
- swapByteOrder(dst.nextrefsyms);
- swapByteOrder(dst.indirectsymoff);
- swapByteOrder(dst.nindirectsyms);
- swapByteOrder(dst.extreloff);
- swapByteOrder(dst.nextrel);
- swapByteOrder(dst.locreloff);
- swapByteOrder(dst.nlocrel);
-}
-
-
-inline void swapStruct(llvm::MachO::any_relocation_info &reloc) {
- swapByteOrder(reloc.r_word0);
- swapByteOrder(reloc.r_word1);
-}
-
-inline void swapStruct(llvm::MachO::nlist &sym) {
- swapByteOrder(sym.n_strx);
- swapByteOrder(sym.n_desc);
- swapByteOrder(sym.n_value);
-}
-
-inline void swapStruct(llvm::MachO::nlist_64 &sym) {
- swapByteOrder(sym.n_strx);
- swapByteOrder(sym.n_desc);
- swapByteOrder(sym.n_value);
-}
-
-
-
inline uint16_t read16(bool swap, uint16_t value) {
return (swap ? getSwappedBytes(value) : value);
}
More information about the llvm-commits
mailing list