]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/mep-relocs.pl
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / mep-relocs.pl
index a4f10d3809f7697d172ef240f99f931c05da59ab..2037c4c935e55b5ecd04325973144c6aec606cff 100755 (executable)
@@ -2,7 +2,7 @@
 # -*- perl -*-
 #
 # Toshiba MeP Media Engine Relocation Generator
-# Copyright (C) 2001, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001-2021 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,
@@ -156,20 +156,23 @@ sub emit_apply {
            $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) {
@@ -183,11 +186,11 @@ sub emit_apply {
                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";
            }