Committed, CRIS: elf32-cris.c: Don't SEGV on invalid input. Add ld/testsuite/ld-cris.
Hans-Peter Nilsson
hans-peter.nilsson@axis.com
Mon Jan 21 16:59:00 GMT 2002
Avoids a SEGV on invalid input (after lots of error messages).
Also introduces ld/testsuite/ld-cris.
bfd:
* elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_32_GOTREL>:
Check for and emit error if sgot is NULL at this point.
ld/testsuite:
* ld-cris: New testsuite directory.
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.22
diff -p -c -r1.22 elf32-cris.c
*** elf32-cris.c 2001/12/17 00:52:35 1.22
--- elf32-cris.c 2002/01/21 21:31:32
*************** cris_elf_relocate_section (output_bfd, i
*** 1162,1167 ****
--- 1162,1181 ----
return false;
}
+ /* This can happen if we get a link error with the input ELF
+ variant mismatching the output variant. Emit an error so
+ it's noticed if it happens elsewhere. */
+ if (sgot == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: relocation %s in section %s with no GOT created"),
+ bfd_archive_filename (input_bfd),
+ cris_elf_howto_table[r_type].name,
+ bfd_get_section_name (input_bfd, input_section));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
/* This relocation is like a PC-relative one, except the
reference point is the location of GOT. Note that
sgot->output_offset is not involved in this calculation. We
*** /dev/null Tue Jan 1 05:00:00 1980
--- ld-cris/badgotr1.d Mon Jan 21 22:29:17 2002
***************
*** 0 ****
--- 1,11 ----
+ #source: gotrel1.s
+ #as: --pic
+ #ld: -m crislinux -shared
+ #objdump: -dr
+ #error: ^[^c][^h][^i][^l][^d].* uses _-prefixed .* failed to merge .* no GOT .* Bad value$
+
+ # The error regex above is supposed to not match if we get a
+ # SEGV, in which case we'll see "child killed: segmentation
+ # violation", supposedly at the beginning (seen) or end (in
+ # theory) of it. The input ELF type (with underscores on
+ # symbols) mismatches the output type (no underscores).
diff -cprN /dev/null ld-cris/cris.exp
*** /dev/null Thu Jan 1 01:00:00 1970
--- ld-cris/cris.exp Mon Jan 21 20:46:53 2002
***************
*** 0 ****
--- 1,30 ----
+ # Expect script for ld-cris tests
+ # Copyright 2002 Free Software Foundation, Inc.
+ #
+ # This file is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ #
+ # Written by Hans-Peter Nilsson (hp@axis.com)
+ #
+
+ if ![istarget cris-*-*] {
+ return
+ }
+
+ set rd_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+ foreach atest $rd_test_list {
+ # We need to strip the ".d", but can leave the dirname.
+ verbose [file rootname $atest]
+ run_dump_test [file rootname $atest]
+ }
diff -cprN /dev/null ld-cris/gotrel1.s
*** /dev/null Thu Jan 1 01:00:00 1970
--- ld-cris/gotrel1.s Mon Jan 21 21:22:08 2002
***************
*** 0 ****
--- 1,4 ----
+ .global _start
+ _start:
+ localsym:
+ move.d localsym:GOTOFF,$r3
brgds, H-P
More information about the Binutils
mailing list