# -*- perl -*-
#
# Toshiba MeP Media Engine Relocation Generator
-# Copyright (C) 2001, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
# This file is part of BFD.
# Originally written by DJ Delorie <dj@redhat.com>
#
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
$e = '^e4' # endian swap for data
}
print NEW " case R_MEP_$relocs[$i]: /* $pattern[$i] */\n";
+ if ($relocs[$i] =~ /HI16S/) {
+ print NEW " u += 0x8000;\n"
+ }
if ($attrs[$i] =~ /tp-rel/i) {
- print NEW " $v -= mep_tpoff_base(rel->r_offset);\n";
+ print NEW " u -= mep_tpoff_base(rel->r_offset);\n";
}
if ($attrs[$i] =~ /gp-rel/i) {
- print NEW " $v -= mep_sdaoff_base(rel->r_offset);\n";
+ print NEW " u -= mep_sdaoff_base(rel->r_offset);\n";
}
if ($attrs[$i] !~ /no-overflow/ && $bits[$i] < 32) {
if ($v eq "u") {
$max = (1 << $bits[$i]) - 1;
print NEW " if (u > $max) r = bfd_reloc_overflow;\n";
} else {
- $min = -(1 << ($bits[$i]-1));
- $max = (1 << ($bits[$i]-1)) - 1;
- print NEW " if ($min > s || s > $max) r = bfd_reloc_overflow;\n";
+ $min = (1 << ($bits[$i]-1));
+ $max = (1 << ($bits[$i])) - 1;
+ print NEW " if (u + $min > $max) r = bfd_reloc_overflow;\n";
}
}
for ($b=0; $b<length($pattern[$i]); $b += 8) {
print NEW " byte[$bb$e] = ";
print NEW "(byte[$bb$e] & 0x$rmask) | " if $rmask ne "00";
if ($left) {
- print NEW "(($v << $left) & 0x$mask)";
+ print NEW "((u << $left) & 0x$mask)";
} elsif ($right) {
- print NEW "(($v >> $right) & 0x$mask)";
+ print NEW "((u >> $right) & 0x$mask)";
} else {
- print NEW "($v & 0x$mask)";
+ print NEW "(u & 0x$mask)";
}
print NEW ";\n";
}