This is an archive of the discontinued LLVM Phabricator instance.

RFC: [LLD] [COFF] Include VirtualSize when sizing sections
AbandonedPublic

Authored by mstorsjo on Feb 15 2021, 3:23 AM.

Details

Reviewers
rnk
Summary

This fixes cases where the Go compiler created bss sections with a zero SizeOfRawData, with the size commnicated via the VirtualSize field.

GNU ld does pick up on and allocate section size based on VirtualSize in addition to SizeOfRawData.

See https://bugs.llvm.org/show_bug.cgi?id=49172 for the full backstory. I'm not entirely sure it's worthwhile doing (if this is the only case that happens to allocate bss sections differently, and it's getting fixed upstream there), and the fix looks overly generic like it could have a number of other unexpected side effects, but it doesn't at least trigger any change in any test case.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Feb 15 2021, 3:23 AM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2021, 3:23 AM
rnk added a comment.Feb 23 2021, 3:57 PM

Is it possible to create objects with bss sections like this when enabling -fcommon? I vaguely recall running into a few cases where common linkage mattered in chrome.

rnk added a comment.Feb 23 2021, 4:03 PM
In D96698#2583410, @rnk wrote:

Is it possible to create objects with bss sections like this when enabling -fcommon? I vaguely recall running into a few cases where common linkage mattered in chrome.

I played around a bit, but I wasn't able to get LLVM to make anything like the object described. I think I would prefer not to put this conditional in the hot path if we agree that tools shouldn't produce objects like this.

mstorsjo abandoned this revision.Feb 23 2021, 11:22 PM
In D96698#2583410, @rnk wrote:

Is it possible to create objects with bss sections like this when enabling -fcommon? I vaguely recall running into a few cases where common linkage mattered in chrome.

No, commons are handled entirely differently.

In D96698#2583428, @rnk wrote:

I played around a bit, but I wasn't able to get LLVM to make anything like the object described. I think I would prefer not to put this conditional in the hot path if we agree that tools shouldn't produce objects like this.

Yeah I'd tend to agree at this point. From the outset of the bug report, it seemed like a potentially valid case (as there's two size fields one could use for conveying the size in the case of bss sections where there's no actual data in the object file anyway), but given that the fix is highly generic and essentially could affect handling of all object files' sections, I think we'd rather not do it. The issue has been fixed on the Go side now anyways.