Page MenuHomePhabricator

MC: Add support for BigObj
ClosedPublic

Authored by majnemer on Sep 14 2014, 9:33 PM.

Details

Summary

Teach WinCOFFObjectWriter how to write -mbig-obj style object files;
these object files allow for more sections inside an object file.

Our support for BigObj is notable different from binutils and cl: we
implicitly upgrade object files to BigObj instead of asking the user to
compile the same file *again* but with another flag. This matches up
with how LLVM treats ELF variants.

This was tested by forcing LLVM to always emit BigObj files and running
the entire test suite. A specific test hasn't been added because I feel
it is prohibitively expensive to add such a test.

I've lowered the maximum number of sections in a normal COFF file,
VS "14" CTP 3 supports no more than 65279 sections. This is important
otherwise we might not switch to BigObj quickly enough, leaving us with
a COFF file that we couldn't link.

yaml2obj support is all that remains to implement.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 13691.Sep 14 2014, 9:33 PM
majnemer retitled this revision from to MC: Add support for BigObj.
majnemer updated this object.
majnemer added reviewers: ruiu, rnk, Bigcheese.
majnemer added a subscriber: Unknown Object (MLST).
rnk accepted this revision.Sep 15 2014, 9:58 AM
rnk edited edge metadata.

Looks fine to me. Up to you if you want to wait for Rui for a more object-file oriented review.

lib/MC/WinCOFFObjectWriter.cpp
658 ↗(On Diff #13691)

Write8(0) doesn't have a loop? *shrug*

662 ↗(On Diff #13691)

WriteLE16(0)?

This revision is now accepted and ready to land.Sep 15 2014, 9:58 AM
rnk added a comment.Sep 15 2014, 10:00 AM

Actually, can you test this from a .s file with 65K sections? Would that be cheap enough?

ruiu edited edge metadata.Sep 15 2014, 10:02 AM

LGTM

Because BigObj is only for object files and not for executables, we are not
going to use the writer for the linker, though.

lib/MC/WinCOFFObjectWriter.cpp
884 ↗(On Diff #13691)

You can just break here.

887 ↗(On Diff #13691)

Offset += SymbolSize?

In D5349#7, @rnk wrote:

Actually, can you test this from a .s file with 65K sections? Would that be cheap enough?

That takes a solid second on my beefy machine. If you feel like that's acceptable, I'll add one.

majnemer closed this revision.Sep 15 2014, 12:52 PM
majnemer updated this revision to Diff 13728.

Closed by commit rL217812 (authored by @majnemer).

Hi,

Visual C++ 2013 Update 2 does not like this change:

1> WinCOFFObjectWriter.cpp
1>..\..\..\lib\MC\WinCOFFObjectWriter.cpp(601): error C2070: 'unknown':
illegal sizeof operand
1>..\..\..\lib\MC\WinCOFFObjectWriter.cpp(602): error C2070: 'unknown':
illegal sizeof operand
1>..\..\..\lib\MC\WinCOFFObjectWriter.cpp(603): error C2070: 'unknown':
illegal sizeof operand
1>..\..\..\lib\MC\WinCOFFObjectWriter.cpp(604): error C2070: 'unknown':
illegal sizeof operand

Yaron

2014-09-15 22:52 GMT+03:00 David Majnemer <david.majnemer@gmail.com>:

Closed by commit rL217812 (authored by @majnemer).

REPOSITORY

rL LLVM

http://reviews.llvm.org/D5349

Files:

llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/include/llvm/Support/COFF.h
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/obj2yaml/coff2yaml.cpp
llvm/trunk/tools/yaml2obj/yaml2coff.cpp

llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits