aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-12-14 21:13:21 +1030
committerAlan Modra <amodra@gmail.com>2021-12-15 08:23:10 +1030
commiteda0ddeb26a117660f3c0f54572053117641c2c3 (patch)
tree757d6033615d4a4bd0d45bad65083686b5c744e2 /bfd/coffcode.h
parent237f6eac1577223034a3e3436bd270428d097534 (diff)
downloadbinutils-eda0ddeb26a117660f3c0f54572053117641c2c3.zip
binutils-eda0ddeb26a117660f3c0f54572053117641c2c3.tar.gz
binutils-eda0ddeb26a117660f3c0f54572053117641c2c3.tar.bz2
XCOFF C_STSYM test failure on 32-bit host
This test was failing here and on another similar symbol: [ 4](sec 1)(fl 0x00)(ty 0)(scl 143) (nx 0) 0x05d1745d11745d21 .bs where correct output is [ 4](sec 1)(fl 0x00)(ty 0)(scl 143) (nx 0) 0x000000000000000a .bs The problem is caused by a 32-bit host pointer being sign-extended when stored into a 64-bit bfd_vma, and then that value not being trimmed back to 32 bits when used. The following belt-and-braces patch fixes both the store and subsequent reads. * coffcode.h (coff_slurp_symbol_table): Do not sign extend when storing a host pointer to syment.n_value. * coffgen.c (coff_get_symbol_info): Cast syment.n_value to a bfd_hostptr_t before using in arithmetic. (coff_print_symbol): Likewise.
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index e2b2566..4405c9f 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -4826,8 +4826,8 @@ coff_slurp_symbol_table (bfd * abfd)
/* The value is actually a symbol index. Save a pointer
to the symbol instead of the index. FIXME: This
should use a union. */
- src->u.syment.n_value =
- (long) (intptr_t) (native_symbols + src->u.syment.n_value);
+ src->u.syment.n_value
+ = (bfd_hostptr_t) (native_symbols + src->u.syment.n_value);
dst->symbol.value = src->u.syment.n_value;
src->fix_value = 1;
break;