This is an archive of the discontinued LLVM Phabricator instance.

Add support for writing 64-bit symbol tables for archives when offsets become too large for 32-bit
ClosedPublic

Authored by jakehehrlich on Aug 16 2017, 5:39 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

jakehehrlich created this revision.Aug 16 2017, 5:39 PM

You have a bunch of changes here to support individual members >=4G, but I'm not sure there is any need for that.
The bug is just about the whole archive being >=4G so that the member offsets need to be 64 bits.
If you want to support members >=4G I think that can be a separate change since it's not related to the bug.

emaste added a subscriber: emaste.Aug 16 2017, 5:49 PM
emaste added inline comments.
include/llvm/Object/Archive.h
51–52 ↗(On Diff #111438)

The comment still references a 32-bit limit.

phosek added inline comments.Aug 16 2017, 9:19 PM
lib/Object/ArchiveWriter.cpp
502 ↗(On Diff #111438)

You should use static_cast here.

phosek added inline comments.Aug 17 2017, 11:29 AM
lib/Object/ArchiveWriter.cpp
152 ↗(On Diff #111438)

This function is exactly the same as print32 except for the Val type, couldn't you use a single templated function and avoid the printNBits altogether?

  1. Removed changes to allow for > 4GB members as Roland recommended
  2. This had the consequence of nullifying the need for the static cast and the comment change
  3. I merged print32 and print64 into a single file but I did not get rid of printNBits. The decision to switch to outputting a 64-bit symbol table is made dynamically so there will need to be an if statement that calls one template instance or the other of any template that might merge the behaviors. I see 3 possible options
  1. use printNBits as I am
  2. tempalte writeSymbolTable and replace the one call to printNBits in writeArchive with an if statement that decides which print to call. This would also need an if statement to decide which writeSymbolTable to call.
  3. template writeSymbolTable and make a template that does what writeArchive does, call it writeArchiveT. writeArchive will the decide which type to instantiate writeArchiveT with while writeArchiveT will do the work that writeArchive does now.

option 1) seems the least invasive to me personally.

jakehehrlich marked 2 inline comments as done.Aug 17 2017, 4:00 PM

I agree with Rafael's comment. K_MIPS64 is now K_GNU64 and printNBits now uses Kind to determine the size.

  1. I committed the rename and rebased so that this diff now assumes that K_MIPS64 is now K_GNU64
  2. I made all the helpers static
rafael edited edge metadata.Oct 3 2017, 2:03 PM

With r314844 in place it should now be much easier to check if a 64 bit symbol table is needed or not.

jakehehrlich edited the summary of this revision. (Show Details)

I updated this to use the new changes that rafael made. Much clearner. Thanks Rafael!

This change adds --print-armap to the test. After https://reviews.llvm.org/D39379 lands this test will work. If the wrong index is used for "main" then the correct file is unlikely to show up making so this test should check that "main" is being looked up in the correct place.

This revision was automatically updated to reflect the committed changes.