[llvm-commits] [llvm] r145180 - in /llvm/trunk: include/llvm-c/Object.h include/llvm/Object/COFF.h include/llvm/Object/MachO.h include/llvm/Object/ObjectFile.h lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.

Chandler Carruth chandlerc at google.com
Sun Nov 27 02:41:40 PST 2011


On Sun, Nov 27, 2011 at 2:12 AM, Danil Malyshev
<dmalyshev at accesssoftek.com>wrote:

> Author: danil
> Date: Sun Nov 27 04:12:52 2011
> New Revision: 145180
>
> URL: http://llvm.org/viewvc/llvm-project?rev=145180&view=rev
> Log:
> Fixed ObjectFile functions:
> - getSymbolOffset() renamed as getSymbolFileOffset()
> - getSymbolFileOffset(), getSymbolAddress(), getRelocationAddress()
> returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
> - added getRelocationOffset()
> - fixed MachOObjectFile::getSymbolSize()
> - fixed MachOObjectFile::getSymbolSection()
> - fixed MachOObjectFile::getSymbolOffset() for symbols without section
> data.
>

Danil, I've reverted this in r145182 because it broke tests on most of our
build bots:

http://lab.llvm.org:8011/builders/llvm-x86_64-linux/builds/1457

It seems to trigger for all of the platforms, so please run the tests next
time before you commit...

I notice that you didn't update any test files with the commit... was that
intentional? At the least, this needs tests to cover all of the "fixed"
things you mention in your commit. I suspect it will also need updates to
existing tests.


> Modified:
>    llvm/trunk/include/llvm-c/Object.h
>    llvm/trunk/include/llvm/Object/COFF.h
>    llvm/trunk/include/llvm/Object/MachO.h
>    llvm/trunk/include/llvm/Object/ObjectFile.h
>    llvm/trunk/lib/Object/COFFObjectFile.cpp
>    llvm/trunk/lib/Object/ELFObjectFile.cpp
>    llvm/trunk/lib/Object/MachOObjectFile.cpp
>    llvm/trunk/lib/Object/Object.cpp
>    llvm/trunk/tools/llvm-nm/llvm-nm.cpp
>    llvm/trunk/tools/llvm-objdump/MachODump.cpp
>    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
>
> Modified: llvm/trunk/include/llvm-c/Object.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Object.h?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm-c/Object.h (original)
> +++ llvm/trunk/include/llvm-c/Object.h Sun Nov 27 04:12:52 2011
> @@ -73,11 +73,12 @@
>  // SymbolRef accessors
>  const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
>  uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
> -uint64_t LLVMGetSymbolOffset(LLVMSymbolIteratorRef SI);
> +uint64_t LLVMGetSymbolFileOffset(LLVMSymbolIteratorRef SI);
>  uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
>
>  // RelocationRef accessors
>  uint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI);
> +uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
>  LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef
> RI);
>  uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
>  // NOTE: Caller takes ownership of returned string of the two
>
> Modified: llvm/trunk/include/llvm/Object/COFF.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/COFF.h (original)
> +++ llvm/trunk/include/llvm/Object/COFF.h Sun Nov 27 04:12:52 2011
> @@ -105,7 +105,7 @@
>  protected:
>   virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
>   virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const;
> -  virtual error_code getSymbolOffset(DataRefImpl Symb, uint64_t &Res)
> const;
> +  virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const;
>   virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res)
> const;
> @@ -135,6 +135,8 @@
>                                        RelocationRef &Res) const;
>   virtual error_code getRelocationAddress(DataRefImpl Rel,
>                                           uint64_t &Res) const;
> +  virtual error_code getRelocationOffset(DataRefImpl Rel,
> +                                         uint64_t &Res) const;
>   virtual error_code getRelocationSymbol(DataRefImpl Rel,
>                                          SymbolRef &Res) const;
>   virtual error_code getRelocationType(DataRefImpl Rel,
>
> Modified: llvm/trunk/include/llvm/Object/MachO.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/MachO.h (original)
> +++ llvm/trunk/include/llvm/Object/MachO.h Sun Nov 27 04:12:52 2011
> @@ -49,7 +49,7 @@
>  protected:
>   virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
>   virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const;
> -  virtual error_code getSymbolOffset(DataRefImpl Symb, uint64_t &Res)
> const;
> +  virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const;
>   virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res)
> const;
> @@ -79,6 +79,8 @@
>                                        RelocationRef &Res) const;
>   virtual error_code getRelocationAddress(DataRefImpl Rel,
>                                           uint64_t &Res) const;
> +  virtual error_code getRelocationOffset(DataRefImpl Rel,
> +                                         uint64_t &Res) const;
>   virtual error_code getRelocationSymbol(DataRefImpl Rel,
>                                          SymbolRef &Res) const;
>   virtual error_code getRelocationType(DataRefImpl Rel,
>
> Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Object/ObjectFile.h Sun Nov 27 04:12:52 2011
> @@ -104,6 +104,7 @@
>   error_code getNext(RelocationRef &Result) const;
>
>   error_code getAddress(uint64_t &Result) const;
> +  error_code getOffset(uint64_t &Result) const;
>   error_code getSymbol(SymbolRef &Result) const;
>   error_code getType(uint64_t &Result) const;
>
> @@ -195,7 +196,7 @@
>
>   error_code getName(StringRef &Result) const;
>   error_code getAddress(uint64_t &Result) const;
> -  error_code getOffset(uint64_t &Result) const;
> +  error_code getFileOffset(uint64_t &Result) const;
>   error_code getSize(uint64_t &Result) const;
>   error_code getType(SymbolRef::Type &Result) const;
>
> @@ -254,7 +255,7 @@
>   virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const
> = 0;
>   virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const
> = 0;
>   virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res)
> const =0;
> -  virtual error_code getSymbolOffset(DataRefImpl Symb, uint64_t &Res)
> const =0;
> +  virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res)
> const =0;
>   virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const
> = 0;
>   virtual error_code getSymbolType(DataRefImpl Symb,
>                                    SymbolRef::Type &Res) const = 0;
> @@ -289,6 +290,8 @@
>                                        RelocationRef &Res) const = 0;
>   virtual error_code getRelocationAddress(DataRefImpl Rel,
>                                           uint64_t &Res) const =0;
> +  virtual error_code getRelocationOffset(DataRefImpl Rel,
> +                                         uint64_t &Res) const =0;
>   virtual error_code getRelocationSymbol(DataRefImpl Rel,
>                                          SymbolRef &Res) const = 0;
>   virtual error_code getRelocationType(DataRefImpl Rel,
> @@ -363,8 +366,8 @@
>   return OwningObject->getSymbolAddress(SymbolPimpl, Result);
>  }
>
> -inline error_code SymbolRef::getOffset(uint64_t &Result) const {
> -  return OwningObject->getSymbolOffset(SymbolPimpl, Result);
> +inline error_code SymbolRef::getFileOffset(uint64_t &Result) const {
> +  return OwningObject->getSymbolFileOffset(SymbolPimpl, Result);
>  }
>
>  inline error_code SymbolRef::getSize(uint64_t &Result) const {
> @@ -486,6 +489,10 @@
>   return OwningObject->getRelocationAddress(RelocationPimpl, Result);
>  }
>
> +inline error_code RelocationRef::getOffset(uint64_t &Result) const {
> +  return OwningObject->getRelocationOffset(RelocationPimpl, Result);
> +}
> +
>  inline error_code RelocationRef::getSymbol(SymbolRef &Result) const {
>   return OwningObject->getRelocationSymbol(RelocationPimpl, Result);
>  }
>
> Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Sun Nov 27 04:12:52 2011
> @@ -101,7 +101,7 @@
>   return getSymbolName(symb, Result);
>  }
>
> -error_code COFFObjectFile::getSymbolOffset(DataRefImpl Symb,
> +error_code COFFObjectFile::getSymbolFileOffset(DataRefImpl Symb,
>                                             uint64_t &Result) const {
>   const coff_symbol *symb = toSymb(Symb);
>   const coff_section *Section = NULL;
> @@ -113,7 +113,7 @@
>   if (Type == 'U' || Type == 'w')
>     Result = UnknownAddressOrSize;
>   else if (Section)
> -    Result = Section->VirtualAddress + symb->Value;
> +    Result = Section->PointerToRawData + symb->Value;
>   else
>     Result = symb->Value;
>   return object_error::success;
> @@ -131,11 +131,9 @@
>   if (Type == 'U' || Type == 'w')
>     Result = UnknownAddressOrSize;
>   else if (Section)
> -    Result = reinterpret_cast<uintptr_t>(base() +
> -                                         Section->PointerToRawData +
> -                                         symb->Value);
> +    Result = Section->VirtualAddress + symb->Value;
>   else
> -    Result = reinterpret_cast<uintptr_t>(base() + symb->Value);
> +    Result = symb->Value;
>   return object_error::success;
>  }
>
> @@ -624,6 +622,11 @@
>   Res = toRel(Rel)->VirtualAddress;
>   return object_error::success;
>  }
> +error_code COFFObjectFile::getRelocationOffset(DataRefImpl Rel,
> +                                               uint64_t &Res) const {
> +  Res = toRel(Rel)->VirtualAddress;
> +  return object_error::success;
> +}
>  error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel,
>                                                SymbolRef &Res) const {
>   const coff_relocation* R = toRel(Rel);
>
> Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Sun Nov 27 04:12:52 2011
> @@ -325,7 +325,7 @@
>  protected:
>   virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
>   virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const;
> -  virtual error_code getSymbolOffset(DataRefImpl Symb, uint64_t &Res)
> const;
> +  virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res)
> const;
>   virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const;
>   virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res)
> const;
> @@ -355,6 +355,8 @@
>                                        RelocationRef &Res) const;
>   virtual error_code getRelocationAddress(DataRefImpl Rel,
>                                           uint64_t &Res) const;
> +  virtual error_code getRelocationOffset(DataRefImpl Rel,
> +                                         uint64_t &Res) const;
>   virtual error_code getRelocationSymbol(DataRefImpl Rel,
>                                          SymbolRef &Res) const;
>   virtual error_code getRelocationType(DataRefImpl Rel,
> @@ -462,7 +464,7 @@
>
>  template<support::endianness target_endianness, bool is64Bits>
>  error_code ELFObjectFile<target_endianness, is64Bits>
> -                        ::getSymbolOffset(DataRefImpl Symb,
> +                        ::getSymbolFileOffset(DataRefImpl Symb,
>                                           uint64_t &Result) const {
>   validateSymbol(Symb);
>   const Elf_Sym  *symb = getSymbol(Symb);
> @@ -486,7 +488,8 @@
>   case ELF::STT_FUNC:
>   case ELF::STT_OBJECT:
>   case ELF::STT_NOTYPE:
> -    Result = symb->st_value;
> +    Result = symb->st_value +
> +             (Section ? Section->sh_offset - Section->sh_addr : 0);
>     return object_error::success;
>   default:
>     Result = UnknownAddressOrSize;
> @@ -502,28 +505,25 @@
>   const Elf_Sym  *symb = getSymbol(Symb);
>   const Elf_Shdr *Section;
>   switch (getSymbolTableIndex(symb)) {
> -  case ELF::SHN_COMMON: // Fall through.
> +  case ELF::SHN_COMMON:
>    // Undefined symbols have no address yet.
>   case ELF::SHN_UNDEF:
>     Result = UnknownAddressOrSize;
>     return object_error::success;
>   case ELF::SHN_ABS:
> -    Result = reinterpret_cast<uintptr_t>(base()+symb->st_value);
> +    Result = symb->st_value;
>     return object_error::success;
>   default: Section = getSection(symb);
>   }
> -  const uint8_t* addr = base();
> -  if (Section)
> -    addr += Section->sh_offset;
> +
>   switch (symb->getType()) {
>   case ELF::STT_SECTION:
> -    Result = reinterpret_cast<uintptr_t>(addr);
> +    Result = Section ? Section->sh_addr : UnknownAddressOrSize;
>     return object_error::success;
> -  case ELF::STT_FUNC: // Fall through.
> -  case ELF::STT_OBJECT: // Fall through.
> +  case ELF::STT_FUNC:
> +  case ELF::STT_OBJECT:
>   case ELF::STT_NOTYPE:
> -    addr += symb->st_value;
> -    Result = reinterpret_cast<uintptr_t>(addr);
> +    Result = symb->st_value;
>     return object_error::success;
>   default:
>     Result = UnknownAddressOrSize;
> @@ -922,6 +922,29 @@
>
>  template<support::endianness target_endianness, bool is64Bits>
>  error_code ELFObjectFile<target_endianness, is64Bits>
> +                        ::getRelocationOffset(DataRefImpl Rel,
> +                                              uint64_t &Result) const {
> +  uint64_t offset;
> +  const Elf_Shdr *sec = getSection(Rel.w.b);
> +  switch (sec->sh_type) {
> +    default :
> +      report_fatal_error("Invalid section type in Rel!");
> +    case ELF::SHT_REL : {
> +      offset = getRel(Rel)->r_offset;
> +      break;
> +    }
> +    case ELF::SHT_RELA : {
> +      offset = getRela(Rel)->r_offset;
> +      break;
> +    }
> +  }
> +
> +  Result = offset - sec->sh_addr;
> +  return object_error::success;
> +}
> +
> +template<support::endianness target_endianness, bool is64Bits>
> +error_code ELFObjectFile<target_endianness, is64Bits>
>                         ::getRelocationType(DataRefImpl Rel,
>                                             uint64_t &Result) const {
>   const Elf_Shdr *sec = getSection(Rel.w.b);
>
> Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Sun Nov 27 04:12:52 2011
> @@ -125,23 +125,27 @@
>   return object_error::success;
>  }
>
> -error_code MachOObjectFile::getSymbolOffset(DataRefImpl DRI,
> -                                             uint64_t &Result) const {
> -  uint64_t SectionOffset;
> -  uint8_t SectionIndex;
> +error_code MachOObjectFile::getSymbolFileOffset(DataRefImpl DRI,
> +                                                uint64_t &Result) const {
>   if (MachOObj->is64Bit()) {
>     InMemoryStruct<macho::Symbol64TableEntry> Entry;
>     getSymbol64TableEntry(DRI, Entry);
>     Result = Entry->Value;
> -    SectionIndex = Entry->SectionIndex;
> +    if (Entry->SectionIndex) {
> +      InMemoryStruct<macho::Section64> Section;
> +      getSection64(Sections[Entry->SectionIndex-1], Section);
> +      Result += Section->Offset - Section->Address;
> +    }
>   } else {
>     InMemoryStruct<macho::SymbolTableEntry> Entry;
>     getSymbolTableEntry(DRI, Entry);
>     Result = Entry->Value;
> -    SectionIndex = Entry->SectionIndex;
> +    if (Entry->SectionIndex) {
> +      InMemoryStruct<macho::Section> Section;
> +      getSection(Sections[Entry->SectionIndex-1], Section);
> +      Result += Section->Offset - Section->Address;
> +    }
>   }
> -  getSectionAddress(Sections[SectionIndex-1], SectionOffset);
> -  Result -= SectionOffset;
>
>   return object_error::success;
>  }
> @@ -162,7 +166,50 @@
>
>  error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
>                                           uint64_t &Result) const {
> -  Result = UnknownAddressOrSize;
> +  uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands;
> +  uint64_t BeginOffset;
> +  uint64_t EndOffset = 0;
> +  uint8_t SectionIndex;
> +  if (MachOObj->is64Bit()) {
> +    InMemoryStruct<macho::Symbol64TableEntry> Entry;
> +    getSymbol64TableEntry(DRI, Entry);
> +    BeginOffset = Entry->Value;
> +    SectionIndex = Entry->SectionIndex;
> +    if (!SectionIndex) {
> +      Result = UnknownAddressOrSize;
> +      return object_error::success;
> +    }
> +    DRI.d.b++;
> +    moveToNextSymbol(DRI);
> +    if (DRI.d.a < LoadCommandCount) {
> +      getSymbol64TableEntry(DRI, Entry);
> +      if (Entry->SectionIndex == SectionIndex)
> +        EndOffset += Entry->Value;
> +    }
> +  } else {
> +    InMemoryStruct<macho::SymbolTableEntry> Entry;
> +    getSymbolTableEntry(DRI, Entry);
> +    BeginOffset = Entry->Value;
> +    SectionIndex = Entry->SectionIndex;
> +    if (!SectionIndex) {
> +      Result = UnknownAddressOrSize;
> +      return object_error::success;
> +    }
> +    DRI.d.b++;
> +    moveToNextSymbol(DRI);
> +    if (DRI.d.a < LoadCommandCount) {
> +      getSymbolTableEntry(DRI, Entry);
> +      if (Entry->SectionIndex == SectionIndex)
> +        EndOffset += Entry->Value;
> +    }
> +  }
> +  if (!EndOffset) {
> +    uint64_t Size;
> +    getSectionSize(Sections[SectionIndex-1], Size);
> +    getSectionAddress(Sections[SectionIndex-1], EndOffset);
> +    EndOffset += Size;
> +  }
> +  Result = EndOffset - BeginOffset;
>   return object_error::success;
>  }
>
> @@ -275,7 +322,7 @@
>   if (index == 0)
>     Res = end_sections();
>   else
> -    Res = section_iterator(SectionRef(Sections[index], this));
> +    Res = section_iterator(SectionRef(Sections[index-1], this));
>
>   return object_error::success;
>  }
> @@ -614,7 +661,7 @@
>   bool isScattered = (Arch != Triple::x86_64) &&
>                      (RE->Word0 & macho::RF_Scattered);
>   uint64_t RelAddr = 0;
> -  if (isScattered)
> +  if (isScattered)
>     RelAddr = RE->Word0 & 0xFFFFFF;
>   else
>     RelAddr = RE->Word0;
> @@ -622,6 +669,20 @@
>   Res = reinterpret_cast<uintptr_t>(sectAddress + RelAddr);
>   return object_error::success;
>  }
> +error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
> +                                                uint64_t &Res) const {
> +  InMemoryStruct<macho::RelocationEntry> RE;
> +  getRelocation(Rel, RE);
> +
> +  unsigned Arch = getArch();
> +  bool isScattered = (Arch != Triple::x86_64) &&
> +                     (RE->Word0 & macho::RF_Scattered);
> +  if (isScattered)
> +    Res = RE->Word0 & 0xFFFFFF;
> +  else
> +    Res = RE->Word0;
> +  return object_error::success;
> +}
>  error_code MachOObjectFile::getRelocationSymbol(DataRefImpl Rel,
>                                                 SymbolRef &Res) const {
>   InMemoryStruct<macho::RelocationEntry> RE;
>
> Modified: llvm/trunk/lib/Object/Object.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/Object.cpp (original)
> +++ llvm/trunk/lib/Object/Object.cpp Sun Nov 27 04:12:52 2011
> @@ -150,9 +150,9 @@
>   return ret;
>  }
>
> -uint64_t LLVMGetSymbolOffset(LLVMSymbolIteratorRef SI) {
> +uint64_t LLVMGetSymbolFileOffset(LLVMSymbolIteratorRef SI) {
>   uint64_t ret;
> -  if (error_code ec = (*unwrap(SI))->getOffset(ret))
> +  if (error_code ec = (*unwrap(SI))->getFileOffset(ret))
>     report_fatal_error(ec.message());
>   return ret;
>  }
> @@ -172,6 +172,13 @@
>   return ret;
>  }
>
> +uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI) {
> +  uint64_t ret;
> +  if (error_code ec = (*unwrap(RI))->getOffset(ret))
> +    report_fatal_error(ec.message());
> +  return ret;
> +}
> +
>  LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef
> RI) {
>   SymbolRef ret;
>   if (error_code ec = (*unwrap(RI))->getSymbol(ret))
>
> Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
> +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Sun Nov 27 04:12:52 2011
> @@ -286,7 +286,7 @@
>       if (error(i->getSize(s.Size))) break;
>     }
>     if (PrintAddress)
> -      if (error(i->getOffset(s.Address))) break;
> +      if (error(i->getFileOffset(s.Address))) break;
>     if (error(i->getNMTypeChar(s.TypeChar))) break;
>     if (error(i->getName(s.Name))) break;
>     SymbolList.push_back(s);
>
> Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Sun Nov 27 04:12:52 2011
> @@ -419,7 +419,7 @@
>
>       // Start at the address of the symbol relative to the section's
> address.
>       uint64_t Start = 0;
> -      Symbols[SymIdx].getOffset(Start);
> +      Symbols[SymIdx].getFileOffset(Start);
>
>       // Stop disassembling either at the beginning of the next symbol or
> at
>       // the end of the section.
> @@ -432,7 +432,7 @@
>         if (NextSymType == SymbolRef::ST_Function) {
>           Sections[SectIdx].containsSymbol(Symbols[NextSymIdx],
>                                            containsNextSym);
> -          Symbols[NextSymIdx].getOffset(NextSym);
> +          Symbols[NextSymIdx].getFileOffset(NextSym);
>           break;
>         }
>         ++NextSymIdx;
>
> Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=145180&r1=145179&r2=145180&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sun Nov 27 04:12:52 2011
> @@ -186,7 +186,7 @@
>       bool contains;
>       if (!error(i->containsSymbol(*si, contains)) && contains) {
>         uint64_t Address;
> -        if (error(si->getOffset(Address))) break;
> +        if (error(si->getFileOffset(Address))) break;
>         StringRef Name;
>         if (error(si->getName(Name))) break;
>         Symbols.push_back(std::make_pair(Address, Name));
> @@ -485,7 +485,7 @@
>       uint64_t Size;
>       section_iterator Section = o->end_sections();
>       if (error(si->getName(Name))) continue;
> -      if (error(si->getOffset(Offset))) continue;
> +      if (error(si->getFileOffset(Offset))) continue;
>       if (error(si->isGlobal(Global))) continue;
>       if (error(si->getType(Type))) continue;
>       if (error(si->isWeak(Weak))) continue;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111127/985063a3/attachment.html>


More information about the llvm-commits mailing list