swapStruct extracted into include/llvm/Support/MachO.h (no functional change)
authorArtyom Skrobov <Artyom.Skrobov@arm.com>
Fri, 18 Jul 2014 09:28:10 +0000 (09:28 +0000)
committerArtyom Skrobov <Artyom.Skrobov@arm.com>
Fri, 18 Jul 2014 09:28:10 +0000 (09:28 +0000)
llvm-svn: 213362

lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h

index fcc1879..a5cba0a 100644 (file)
@@ -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 &sect) {
-  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 &sect) {
-  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);
 }