This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Don't abort printing of dynamic table if string reference is invalid
ClosedPublic

Authored by ychen on Jun 10 2019, 11:02 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ychen created this revision.Jun 10 2019, 11:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2019, 11:02 AM
jhenderson accepted this revision.Jun 11 2019, 1:47 AM
jhenderson added a reviewer: rupprecht.

I already gave this an LGTM offline, and that still applies. Somebody else should give this a quick look through though too.

This revision is now accepted and ready to land.Jun 11 2019, 1:47 AM

As you've got D63115 in flight which fixes the FIXME in the test, maybe it would be better holding off committing this until that lands, and then you can avoid having the FIXME at all. What do you think?

Few comments are below. James, what do you think?

llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
157 ↗(On Diff #203863)

<not found> is inconsistent with library name not found below.
Should both use <..>?

llvm/tools/llvm-readobj/ELFDumper.cpp
1779 ↗(On Diff #203863)

It is a bit inconsistent.
I think you need to use upper/lower case for both messages, but do not mix.
I.e dynamic strtab not found -> Dynamic strtab not found.

I would also probably rewrite to "String table is empty or was not found" or something like that.
Because it is possible (in theory) that DT_STRSZ == 0, but DT_STRTAB points to somewhere.

grimar added inline comments.Jun 11 2019, 2:41 AM
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
162 ↗(On Diff #203863)

Perhaps it should use different forms too?

Shared library: [valid_library_name.so]
Shared library: <dynamic strtab not found>

jhenderson added inline comments.Jun 11 2019, 3:12 AM
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
157 ↗(On Diff #203863)

As we might change the below output based on GNU, let's make it consistent with that style, if it makes sense. If GNU doesn't print with any markers, then I'm happy with either style, but consistency would be good.

162 ↗(On Diff #203863)

What does GNU's output look like? If it produces an inline message here, we should probably mirror that, thinking about it.

ychen added a comment.Jun 11 2019, 9:08 AM

As you've got D63115 in flight which fixes the FIXME in the test, maybe it would be better holding off committing this until that lands, and then you can avoid having the FIXME at all. What do you think?

Yes, that sounds great.

ychen updated this revision to Diff 204156.Jun 11 2019, 1:40 PM
ychen marked 4 inline comments as done.
  • update
ychen added inline comments.Jun 11 2019, 1:40 PM
llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
157 ↗(On Diff #203863)

done.

162 ↗(On Diff #203863)

GNU only print the index
0x0000000000000001 (NEEDED) 0x1

162 ↗(On Diff #203863)

Agree.

ychen added a comment.Jun 11 2019, 1:41 PM
  • Match GNU output for DT_RPATH and DT_RUNPATH.
  • All diagnose messages enclosed with <>.
  • Test updated accordingly.
ychen updated this revision to Diff 204158.Jun 11 2019, 1:43 PM
  • update
jhenderson accepted this revision.Jun 12 2019, 1:43 AM

My instinct is to say that the RPATH change should be a separate change, since it's not just about the improved error/warning. Please could you split it off (we still want it, just not in a commit to do with error messages). LGTM, aside from that.

MaskRay added inline comments.Jun 12 2019, 1:53 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
1942 ↗(On Diff #204158)

DynamicStringTable.empty()

1947 ↗(On Diff #204158)

O->o i.e. <Invalid offset 0x?

Alternatively, make it all lowercase: <invalid offset 0x. I'm just not sure which style is more common in this file.

MaskRay added inline comments.Jun 12 2019, 1:57 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
1998 ↗(On Diff #204158)

I think not found is not entirely accurate. The issue is that the index into the string table is invalid (out of range). Do other reviewers have suggestion for the message used here?

jhenderson added inline comments.Jun 12 2019, 7:03 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
1998 ↗(On Diff #204158)

You're probably right. It should probably be something like <library name index out of range> or <library name index invalid> like you suggest.

ychen updated this revision to Diff 204335.EditedJun 12 2019, 11:21 AM

Address reviewer's comments.

  • capitalize first char of diagnose strings.
  • split out DT_RPATH & DT_RUNPATH code.
ychen marked 3 inline comments as done.Jun 12 2019, 11:27 AM
ychen added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
1942 ↗(On Diff #204158)

done

1947 ↗(On Diff #204158)

done

1998 ↗(On Diff #204158)

Went with <Library name index out of range>

jhenderson accepted this revision.Jun 13 2019, 1:29 AM

Looks good, with the suggested changes to the if statements.

llvm/tools/llvm-readobj/ELFDumper.cpp
1794 ↗(On Diff #204335)

LLVM standard has the body of an if on a new line, I believe, i.e.

if (WithBracket)
  OS << "[";
1796 ↗(On Diff #204335)

Ditto

1942 ↗(On Diff #204158)

Tip: you can mark individual comments as "Done" by clicking the "Done" button in the comment box header. I find it quite useful when reviewing code if that has been done.

D62072 seems to promote lowercasing the first letter in error messages.

MaskRay accepted this revision.Jun 13 2019, 2:53 AM

D62072 seems to promote lowercasing the first letter in error messages.

Yes, I agree with that, although it's debatable as to whether these are the same, since they aren't independent error messages printed on stderr, so the guidelines might not be the same. I don't really know though!

ychen updated this revision to Diff 204562.Jun 13 2019, 9:09 AM
  • update
ychen marked 5 inline comments as done.Jun 13 2019, 9:13 AM

Thank you @jhenderson @MaskRay. If this looks good, could you commit it for me?

llvm/tools/llvm-readobj/ELFDumper.cpp
1942 ↗(On Diff #204158)

Oh, that's much better.

@grimar, are you happy for me to land this patch?

@grimar, are you happy for me to land this patch?

Sure.

This revision was automatically updated to reflect the committed changes.