[llvm] r221855 - llvm-readobj: Print out address table when dumping COFF delay-import table

Daniel Sanders Daniel.Sanders at imgtec.com
Thu Nov 13 06:01:05 PST 2014


Hi Rui,

I expect you've already had emails from buildbot about this but imports.tests fails on the big-endian hosts. See http://lab.llvm.org:8011/builders/llvm-mips-linux/builds/11120, and http://lab.llvm.org:8011/builders/llvm-ppc64-linux1/builds/15854 for the logs.

> --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Wed Nov 12 21:22:54 2014
> @@ -1258,6 +1258,20 @@ getDelayImportTable(const delay_import_d
>    return object_error::success;
>  }
> 
> +std::error_code DelayImportDirectoryEntryRef::
> +getImportAddress(int AddrIndex, uint64_t &Result) const {
> +  uint32_t RVA = Table[Index].DelayImportAddressTable +
> +      AddrIndex * (OwningObject->is64() ? 8 : 4);
> +  uintptr_t IntPtr = 0;
> +  if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
> +    return EC;
> +  if (OwningObject->is64())
> +    Result = *reinterpret_cast<const uint64_t *>(IntPtr);
> +  else
> +    Result = *reinterpret_cast<const uint32_t *>(IntPtr);
> +  return object_error::success;
> +}

I've looked through your patch and I believe the problem is the two reinterpret_casts. They are reading host-endian values but you need to read target-endian values.




More information about the llvm-commits mailing list