[PATCH] D57009: [llvm-objcopy] [COFF] Fix handling of aux symbols for big objects

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 22 03:33:00 PST 2019


mstorsjo marked an inline comment as done.
mstorsjo added a comment.

In D57009#1366076 <https://reviews.llvm.org/D57009#1366076>, @jhenderson wrote:

> > Other llvm-objcopy reviewers: I'd like to add a custom hidden option for testing, for triggering using the big object format. Without that, a test would have to create over 32k sections to trigger that.
>
> I'm not a fan of adding hidden options purely for testing when there are alternatives. In the ELF tests, we use a pre-built zip file containing an object with many sections (see ELF/many-sections.test). I think you could probably do the same thing here.


Hmm, ok. Now with `--add-gnu-debuglink` it's possible to add a section, so with that I guess it should be possible to achieve a test which removes a section to make the big object small, and then add another one to make it big again. Less elegant than a small and neat yaml test input IMO, but probably tolerable.



================
Comment at: tools/llvm-objcopy/COFF/Writer.cpp:326-328
+        std::copy(S.AuxData.data() + I * sizeof(coff_symbol16),
+                  S.AuxData.data() + (I + 1) * sizeof(coff_symbol16),
+                  Ptr + I * sizeof(SymbolTy));
----------------
jhenderson wrote:
> Are coff_symbol16 and SymbolTy supposed to be the same size? Or are you deliberately writing less (or more) into the buffer than you iterate over?
I'm deliberately writing more or less, yes.

The COFF-ism is that the symbol table can consist of entries of either coff_symbol16 or coff_symbol32, of 18 or 20 bytes each. A symbol can be followed by a number of aux symbols, which can be one of a number of different structs, all 18 bytes each. If the table consists of coff_symbol32 entries, each one of the aux symbols (opaque aux structs) will have 2 bytes of padding at the end.

So here I'm writing chunks of 18 bytes at a time out of the stored AuxData (where they are packed tightly), spaced 18 or 20 bytes apart in the output symbol table (depending on the entry size of that symbol table).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57009/new/

https://reviews.llvm.org/D57009





More information about the llvm-commits mailing list