aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-01-26 09:14:13 +1030
committerAlan Modra <amodra@gmail.com>2024-01-26 17:19:45 +1030
commite14f7abaf81d5d0aa7898570024286de8c188817 (patch)
treeadf6c7bbae99c79c4b554f32d805f6307537f3c0
parent8409b75c8db34f65d1e21ab26c108ff73d73d4e8 (diff)
downloadbinutils-e14f7abaf81d5d0aa7898570024286de8c188817.zip
binutils-e14f7abaf81d5d0aa7898570024286de8c188817.tar.gz
binutils-e14f7abaf81d5d0aa7898570024286de8c188817.tar.bz2
Assertion failure dumping .eh_frame_hdr
dwarf.c can hit "Assertion '(start) <= (end)' failed" on truncated sections, due to get_encoded_eh_value wrongly returning a full count for truncated words. * dwarf.c (get_encoded_eh_value): Return zero for truncated words.
-rw-r--r--binutils/dwarf.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index a30bc1c..1947ab1 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -9236,37 +9236,37 @@ get_encoded_eh_value (unsigned int encoding,
case DW_EH_PE_udata2:
old_start = start;
SAFE_BYTE_GET_AND_INC (val, start, 2, end);
- len = (start == old_start) ? 0 : 2;
+ len = start - old_start == 2 ? 2 : 0;
break;
case DW_EH_PE_udata4:
old_start = start;
SAFE_BYTE_GET_AND_INC (val, start, 4, end);
- len = (start == old_start) ? 0 : 4;
+ len = start - old_start == 4 ? 4 : 0;
break;
case DW_EH_PE_udata8:
old_start = start;
SAFE_BYTE_GET_AND_INC (val, start, 8, end);
- len = (start == old_start) ? 0 : 8;
+ len = start - old_start == 8 ? 8 : 0;
break;
case DW_EH_PE_sdata2:
old_start = start;
SAFE_SIGNED_BYTE_GET_AND_INC (val, start, 2, end);
- len = (start == old_start) ? 0 : 2;
+ len = start - old_start == 2 ? 2 : 0;
break;
case DW_EH_PE_sdata4:
old_start = start;
SAFE_SIGNED_BYTE_GET_AND_INC (val, start, 4, end);
- len = (start == old_start) ? 0 : 4;
+ len = start - old_start == 4 ? 4 : 0;
break;
case DW_EH_PE_sdata8:
old_start = start;
SAFE_SIGNED_BYTE_GET_AND_INC (val, start, 8, end);
- len = (start == old_start) ? 0 : 8;
+ len = start - old_start == 8 ? 8 : 0;
break;
default: