Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sabsptr): support for DW_EH_PE_sabsptr #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/dwarf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,13 @@ uint64_t ReadEncodedPointer(uint8_t encoding, bool is_64bit, string_view* data,
case DW_EH_PE_udata8:
value = dwarf::ReadMemcpy<uint64_t>(data);
break;
case DW_EH_PE_sabsptr:
if (is_64bit) {
value = dwarf::ReadMemcpy<int64_t>(data);
} else {
value = dwarf::ReadMemcpy<int32_t>(data);
}
break;
case DW_EH_PE_sleb128:
value = dwarf::ReadLEB128<int64_t>(data);
break;
Expand Down Expand Up @@ -1723,6 +1730,15 @@ uint64_t ReadEncodedPointer(uint8_t encoding, bool is_64bit, string_view* data,
THROWF("Unimplemented eh_frame application value: $0", application);
}

if (encoding & DW_EH_PE_indirect && format == DW_EH_PE_sabsptr) {
// Inspired by comment in https://github.com/gnustep/libobjc2/blob/master/dwarf_eh.h#L196
// The quote:
// "If this is an indirect value, then it is really the address of the real
// value
// TODO: Check whether this should really always be a pointer - it seems to
// be a GCC extensions, so not properly documented..."
return value;
}
if (encoding & DW_EH_PE_indirect) {
string_view location = sink->TranslateVMToFile(value);
if (is_64bit) {
Expand Down
1 change: 1 addition & 0 deletions src/dwarf_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ enum PointerEncoding {
DW_EH_PE_udata2 = 0x02,
DW_EH_PE_udata4 = 0x03,
DW_EH_PE_udata8 = 0x04,
DW_EH_PE_sabsptr = 0x08,
DW_EH_PE_sleb128 = 0x09,
DW_EH_PE_sdata2 = 0x0A,
DW_EH_PE_sdata4 = 0x0B,
Expand Down