aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2003-02-06 23:01:04 +0000
committerAndreas Schwab <schwab@linux-m68k.org>2003-02-06 23:01:04 +0000
commit84f97cb6412ffb7a3e6cc1fda4be14196f9c66ac (patch)
tree95cecd318c573c60da60588b0ea136bb7ac3e340 /bfd
parent9e1d9e8d68c2fb15157177ad27941f7e784d95c0 (diff)
downloadgdb-84f97cb6412ffb7a3e6cc1fda4be14196f9c66ac.zip
gdb-84f97cb6412ffb7a3e6cc1fda4be14196f9c66ac.tar.gz
gdb-84f97cb6412ffb7a3e6cc1fda4be14196f9c66ac.tar.bz2
* elf-eh-frame.c (get_DW_EH_PE_signed): Define.
(read_value): Add parameter is_signed, use signed extraction if the value is signed. (_bfd_elf_write_section_eh_frame): Pass signed flag of the encoding to read_value.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf-eh-frame.c44
2 files changed, 43 insertions, 9 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 085ae78..f802abf 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2003-02-06 Andreas Schwab <schwab@suse.de>
+
+ * elf-eh-frame.c (get_DW_EH_PE_signed): Define.
+ (read_value): Add parameter is_signed, use signed extraction if
+ the value is signed.
+ (_bfd_elf_write_section_eh_frame): Pass signed flag of the
+ encoding to read_value.
+
2003-02-06 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't copy got and
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 3db9453..7764074 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -33,7 +33,7 @@ static bfd_signed_vma read_signed_leb128
static int get_DW_EH_PE_width
PARAMS ((int, int));
static bfd_vma read_value
- PARAMS ((bfd *, bfd_byte *, int));
+ PARAMS ((bfd *, bfd_byte *, int, int));
static void write_value
PARAMS ((bfd *, bfd_byte *, bfd_vma, int));
static int cie_compare
@@ -141,22 +141,42 @@ int get_DW_EH_PE_width (encoding, ptr_size)
return 0;
}
+#define get_DW_EH_PE_signed(encoding) (((encoding) & DW_EH_PE_signed) != 0)
+
/* Read a width sized value from memory. */
static bfd_vma
-read_value (abfd, buf, width)
+read_value (abfd, buf, width, is_signed)
bfd *abfd;
bfd_byte *buf;
int width;
+ int is_signed;
{
bfd_vma value;
switch (width)
{
- case 2: value = bfd_get_16 (abfd, buf); break;
- case 4: value = bfd_get_32 (abfd, buf); break;
- case 8: value = bfd_get_64 (abfd, buf); break;
- default: BFD_FAIL (); return 0;
+ case 2:
+ if (is_signed)
+ value = bfd_get_signed_16 (abfd, buf);
+ else
+ value = bfd_get_16 (abfd, buf);
+ break;
+ case 4:
+ if (is_signed)
+ value = bfd_get_signed_32 (abfd, buf);
+ else
+ value = bfd_get_32 (abfd, buf);
+ break;
+ case 8:
+ if (is_signed)
+ value = bfd_get_signed_64 (abfd, buf);
+ else
+ value = bfd_get_64 (abfd, buf);
+ break;
+ default:
+ BFD_FAIL ();
+ return 0;
}
return value;
@@ -925,7 +945,9 @@ _bfd_elf_write_section_eh_frame (abfd, info, sec, contents)
{
bfd_vma value;
- value = read_value (abfd, buf, per_width);
+ value = read_value (abfd, buf, per_width,
+ get_DW_EH_PE_signed
+ (per_encoding));
value += (sec_info->entry[i].offset
- sec_info->entry[i].new_offset);
write_value (abfd, buf, value, per_width);
@@ -961,7 +983,9 @@ _bfd_elf_write_section_eh_frame (abfd, info, sec, contents)
buf += 4;
width = get_DW_EH_PE_width (sec_info->entry[i].fde_encoding,
ptr_size);
- address = value = read_value (abfd, buf, width);
+ address = value = read_value (abfd, buf, width,
+ get_DW_EH_PE_signed
+ (sec_info->entry[i].fde_encoding));
if (value)
{
switch (sec_info->entry[i].fde_encoding & 0xf0)
@@ -1005,7 +1029,9 @@ _bfd_elf_write_section_eh_frame (abfd, info, sec, contents)
buf += sec_info->entry[i].lsda_offset;
width = get_DW_EH_PE_width (sec_info->entry[i].lsda_encoding,
ptr_size);
- value = read_value (abfd, buf, width);
+ value = read_value (abfd, buf, width,
+ get_DW_EH_PE_signed
+ (sec_info->entry[i].lsda_encoding));
if (value)
{
if ((sec_info->entry[i].lsda_encoding & 0xf0)