This is an archive of the discontinued LLVM Phabricator instance.

[lld][COFF] Remove incorrect flag from EHcont table
ClosedPublic

Authored by namazso on Aug 10 2023, 7:57 AM.

Diff Detail

Event Timeline

namazso created this revision.Aug 10 2023, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 7:57 AM
namazso requested review of this revision.Aug 10 2023, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 7:57 AM

Can you add a multi entries test to show the change, please?

namazso updated this revision to Diff 549079.Aug 10 2023, 9:27 AM

Updated objdump, added a test.

rnk added a comment.Aug 10 2023, 10:01 AM

Thanks!

llvm/tools/llvm-readobj/COFFDumper.cpp
864

You can simplify the code and eliminate all these else clauses by changing this condition above in printRVATable:

  if (PrintExtra)
      PrintExtra(OS, reinterpret_cast<const uint8_t *>(I));
>>
  if (EntrySize == 5)
      PrintExtra(OS, reinterpret_cast<const uint8_t *>(I));

It's not general to more than a byte of flags, but that's true already.

namazso updated this revision to Diff 549105.Aug 10 2023, 10:58 AM

Replaced the previous ehcont test with the new one, as it tests nothing the new one doesn't

@rnk Removed the duplicated ifs. Technically the flags are not defined at all for anything but the CF table, so we could straight up just ignore them, but we don't decode them in the CF table either and instead just dump them out in hex, so might as well just do the same for the rest.

rnk accepted this revision.Aug 10 2023, 11:04 AM

lgtm

This revision is now accepted and ready to land.Aug 10 2023, 11:04 AM
This revision was landed with ongoing or failed builds.Aug 10 2023, 1:18 PM
This revision was automatically updated to reflect the committed changes.
mstorsjo added inline comments.
llvm/tools/llvm-readobj/COFFDumper.cpp
947

This broke compilation with GCC:

../tools/llvm-readobj/COFFDumper.cpp: In member function ‘virtual void {anonymous}::COFFDumper::printCOFFLoadConfig()’:
../tools/llvm-readobj/COFFDumper.cpp:947:41: error: operands to ‘?:’ have different types ‘{anonymous}::COFFDumper::printCOFFLoadConfig()::<lambda(llvm::raw_ostream&, const uint8_t*)>’ and ‘std::nullptr_t’
  947 |   PrintExtraCB PrintExtra = Stride == 1 ? PrintGuardFlags : nullptr;
      |                             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
duck-37 added inline comments.
llvm/tools/llvm-readobj/COFFDumper.cpp
947

Quick-fix pushed up just now. Seems to have worked.

rnk added a comment.Aug 10 2023, 3:55 PM

You can see where the eh cont table was added here: https://reviews.llvm.org/D99078

lld/COFF/Writer.cpp
1799

I think with this change the final parameter of maybeAddRVATable is completely dead. Would you please make a follow up change to remove the code for it?

1876

We don't need RVAFlagTableChunk anymore.

namazso added inline comments.Aug 10 2023, 4:10 PM
lld/COFF/Writer.cpp
1799

I wasn't sure about throwing out all that code since strides exist for a reason, which is the suppression flags (currently unsupported by lld). I guess if (when) someone starts caring about them they can just add it back, in some actually usable way, as in the current one you can't actually control the contents (it's always 0).

Will make a follow-up with the removals.