This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo/DWARF] - Report .eh_frame sections of version != 1.
ClosedPublic

Authored by grimar on Jun 9 2020, 7:06 AM.

Details

Summary

Specification (https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#AEN1349)
says that the value of Version field for .eh_frame should be 1.

Though we accept other values and might perform an attempt to read
it as a .debug_frame because of that, what is wrong.

This patch adds a version check.

Diff Detail

Event Timeline

grimar created this revision.Jun 9 2020, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2020, 7:06 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

If the .eh_frame section contains contributions for multiple compilation units, the dumper should skip over the bad one and continue dumping at the next one. In which case, you'd need only one test, with multiple units in it (imitating a linked executable).

If the .eh_frame section contains contributions for multiple compilation units, the dumper should skip over the bad one and continue dumping at the next one. In which case, you'd need only one test, with multiple units in it (imitating a linked executable).

Sounds reasonable.

But Error DWARFDebugFrame::parse(DWARFDataExtractor Data) returns errors for a few cases already,
e.g. for the case when something is wrong with the augmentation string. Instead it could provide a way to
report a warning (perhaps a warning callback) and continue dumping.

Reimplementing the DWARFDebugFrame::parse() to support warnings should be done independently from this change I think?

One more way to have a single test right now is to use yaml2obj instead of llvm-mc.

With it I'll need to specify a binary blob for the section content though.
(yaml2obj doesn't fully support the .eh_frame section yet I believe)

I.e. it will look like:

Sections:
  - Name: .eh_frame
    Type: SHT_PROGBITS
## A comment describing the content.
    Content: "001122334455"

Should I do it?

One more way to have a single test right now is to use yaml2obj instead of llvm-mc.

With it I'll need to specify a binary blob for the section content though.
(yaml2obj doesn't fully support the .eh_frame section yet I believe)

I.e. it will look like:

Sections:
  - Name: .eh_frame
    Type: SHT_PROGBITS
## A comment describing the content.
    Content: "001122334455"

Should I do it?

Can you just use .byte .long to construct the content of .eh_frame? It will be more reasonable than hex pairs in YAML.

grimar added a comment.EditedJun 11 2020, 1:05 AM

One more way to have a single test right now is to use yaml2obj instead of llvm-mc.

With it I'll need to specify a binary blob for the section content though.
(yaml2obj doesn't fully support the .eh_frame section yet I believe)

I.e. it will look like:

Sections:
  - Name: .eh_frame
    Type: SHT_PROGBITS
## A comment describing the content.
    Content: "001122334455"

Should I do it?

Can you just use .byte .long to construct the content of .eh_frame? It will be more reasonable than hex pairs in YAML.

This is what this patch already does I think? Did you mean using something like
we do in LLD, i.e like the following?

# RUN: echo '.section .eh_frame,"a",@unwind; .long 6; .long 0; .long 2' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tbar.o

It is probably not that nicely readable, though I do not have a strong objection to do in this way if you think it is better than what is done in this patch already.

probinson accepted this revision.Jun 15 2020, 12:45 PM

If the .eh_frame section contains contributions for multiple compilation units, the dumper should skip over the bad one and continue dumping at the next one. In which case, you'd need only one test, with multiple units in it (imitating a linked executable).

Sounds reasonable.

But Error DWARFDebugFrame::parse(DWARFDataExtractor Data) returns errors for a few cases already,
e.g. for the case when something is wrong with the augmentation string. Instead it could provide a way to
report a warning (perhaps a warning callback) and continue dumping.

Reimplementing the DWARFDebugFrame::parse() to support warnings should be done independently from this change I think?

That's fair. LGTM, although it would be nice if you could leave a TODO comment.

This revision is now accepted and ready to land.Jun 15 2020, 12:45 PM

If the .eh_frame section contains contributions for multiple compilation units, the dumper should skip over the bad one and continue dumping at the next one. In which case, you'd need only one test, with multiple units in it (imitating a linked executable).

Sounds reasonable.

But Error DWARFDebugFrame::parse(DWARFDataExtractor Data) returns errors for a few cases already,
e.g. for the case when something is wrong with the augmentation string. Instead it could provide a way to
report a warning (perhaps a warning callback) and continue dumping.

Reimplementing the DWARFDebugFrame::parse() to support warnings should be done independently from this change I think?

That's fair. LGTM, although it would be nice if you could leave a TODO comment.

Will do, thanks!

This revision was automatically updated to reflect the committed changes.