⛏️ index : haiku.git

author KENZ <KENZ.gelsoft@gmail.com> 2023-06-10 7:20:46.0 +09:00:00
committer waddlesplash <waddlesplash@gmail.com> 2023-10-07 19:26:04.0 +00:00:00
commit
dca65c878fdfacac7c975fac1e90b8a40278f430 [patch]
tree
85cfcf26c7448533bcdc9c245c4d0efbb87a2ed4
parent
5c6cea9dd7c6b9de997aadc439d9d8320eadf9b0
download
dca65c878fdfacac7c975fac1e90b8a40278f430.tar.gz

Debugger: just skip .debug_frame/.eh_frame section contains a 0-length CIE

Some executables (or shared objects) may have .debug_frame or
.eh_frame section which contains the CIE(/FDE) length is 0.
The DWARF spec doesn't describe this case explicitly, but doesn't
prohibit it.
LSB says to treat this a terminator of the CIE.

https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html

Previous code failed to load the entire debug info of the
executable.

New code just skip these section (don't read anymore) after the
Debugger (kit) encounter a 0-length CIE.

Fixes #18438.

Change-Id: I382d0ec409d40570b5bccd384d38fa3c29ae2e7f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6538
Reviewed-by: Rene Gollent <rene@gollent.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
(cherry picked from commit f0e9ed4488b00cee222f17b190b0d415019ad17c)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7016
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Diff

 src/kits/debugger/dwarf/DwarfFile.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/kits/debugger/dwarf/DwarfFile.cpp b/src/kits/debugger/dwarf/DwarfFile.cpp
index 0e5cc26..5ccac82 100644
--- a/src/kits/debugger/dwarf/DwarfFile.cpp
+++ b/src/kits/debugger/dwarf/DwarfFile.cpp
@@ -1156,6 +1156,11 @@
			return B_BAD_DATA;
		off_t lengthOffset = dataReader.Offset();

		// If the length is 0, it means a terminator of the CIE.
		// Then just skip this .debug_frame/.eh_frame section.
		if (length == 0)
			return B_OK;

		// CIE ID/CIE pointer
		uint64 cieID = dwarf64
			? dataReader.Read<uint64>(0) : dataReader.Read<uint32>(0);