mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-23 20:19:49 +00:00
Add a testcase for PR binutils/14567
binutils/ PR binutils/14567 * Makefile.am (BFDTEST2_PROG): New. (bfdtest2_DEPENDENCIES): Likewise. (TEST_PROGS): Add $(BFDTEST2_PROG). * Makefile.in: Regenerated. * bfdtest2.c: New file. binutils/testsuite/ PR binutils/14567 * binutils-all/ar.exp (bfdtest1): Removed. (long_filenames): Take bfdtests. (thin_archive): Likewise. (thin_archive_with_nested): Likewise. (bfdtests): New. Pass $bfdtests to long_filenames, thin_archive and thin_archive_with_nested.
This commit is contained in:
parent
87988f9a1d
commit
f7da43f33b
@ -1,3 +1,12 @@
|
||||
2012-11-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR binutils/14567
|
||||
* Makefile.am (BFDTEST2_PROG): New.
|
||||
(bfdtest2_DEPENDENCIES): Likewise.
|
||||
(TEST_PROGS): Add $(BFDTEST2_PROG).
|
||||
* Makefile.in: Regenerated.
|
||||
* bfdtest2.c: New file.
|
||||
|
||||
2012-11-05 Stephane Carrez <Stephane.Carrez@gmail.com>
|
||||
|
||||
* MAINTAINERS: Update my email address.
|
||||
|
@ -67,8 +67,9 @@ EXTRA_SCRIPTS = embedspu
|
||||
|
||||
## Test programs.
|
||||
BFDTEST1_PROG = bfdtest1
|
||||
BFDTEST2_PROG = bfdtest2
|
||||
|
||||
TEST_PROGS = $(BFDTEST1_PROG)
|
||||
TEST_PROGS = $(BFDTEST1_PROG) $(BFDTEST2_PROG)
|
||||
|
||||
## We need a special rule to install the programs which are built with
|
||||
## -new, and to rename cxxfilt to c++filt.
|
||||
@ -200,6 +201,7 @@ readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
|
||||
bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
|
||||
|
||||
LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
|
||||
|
||||
|
@ -41,7 +41,7 @@ bin_PROGRAMS = $(am__EXEEXT_6) $(am__EXEEXT_7) $(am__EXEEXT_8) \
|
||||
@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ \
|
||||
@BUILD_WINDMC@ $(am__EXEEXT_12) $(am__EXEEXT_13) \
|
||||
$(am__EXEEXT_14) @BUILD_DLLWRAP@
|
||||
noinst_PROGRAMS = $(am__EXEEXT_18) $(am__EXEEXT_20) @BUILD_MISC@
|
||||
noinst_PROGRAMS = $(am__EXEEXT_18) $(am__EXEEXT_21) @BUILD_MISC@
|
||||
EXTRA_PROGRAMS = $(am__EXEEXT_1) srconv$(EXEEXT) sysdump$(EXEEXT) \
|
||||
coffdump$(EXEEXT) $(am__EXEEXT_2) $(am__EXEEXT_3) \
|
||||
$(am__EXEEXT_4) $(am__EXEEXT_5)
|
||||
@ -102,7 +102,8 @@ am__EXEEXT_16 = strip-new$(EXEEXT)
|
||||
am__EXEEXT_17 = cxxfilt$(EXEEXT)
|
||||
am__EXEEXT_18 = $(am__EXEEXT_15) $(am__EXEEXT_16) $(am__EXEEXT_17)
|
||||
am__EXEEXT_19 = bfdtest1$(EXEEXT)
|
||||
am__EXEEXT_20 = $(am__EXEEXT_19)
|
||||
am__EXEEXT_20 = bfdtest2$(EXEEXT)
|
||||
am__EXEEXT_21 = $(am__EXEEXT_19) $(am__EXEEXT_20)
|
||||
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
|
||||
am__objects_1 = bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
|
||||
am_addr2line_OBJECTS = addr2line.$(OBJEXT) $(am__objects_1)
|
||||
@ -116,6 +117,9 @@ ar_OBJECTS = $(am_ar_OBJECTS)
|
||||
bfdtest1_SOURCES = bfdtest1.c
|
||||
bfdtest1_OBJECTS = bfdtest1.$(OBJEXT)
|
||||
bfdtest1_LDADD = $(LDADD)
|
||||
bfdtest2_SOURCES = bfdtest2.c
|
||||
bfdtest2_OBJECTS = bfdtest2.$(OBJEXT)
|
||||
bfdtest2_LDADD = $(LDADD)
|
||||
am_coffdump_OBJECTS = coffdump.$(OBJEXT) coffgrok.$(OBJEXT) \
|
||||
$(am__objects_1)
|
||||
coffdump_OBJECTS = $(am_coffdump_OBJECTS)
|
||||
@ -226,7 +230,7 @@ YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
|
||||
LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS)
|
||||
SOURCES = $(addr2line_SOURCES) $(ar_SOURCES) $(EXTRA_ar_SOURCES) \
|
||||
bfdtest1.c $(coffdump_SOURCES) $(cxxfilt_SOURCES) \
|
||||
bfdtest1.c bfdtest2.c $(coffdump_SOURCES) $(cxxfilt_SOURCES) \
|
||||
$(dlltool_SOURCES) $(dllwrap_SOURCES) $(elfedit_SOURCES) \
|
||||
$(nlmconv_SOURCES) $(nm_new_SOURCES) $(objcopy_SOURCES) \
|
||||
$(objdump_SOURCES) $(EXTRA_objdump_SOURCES) $(ranlib_SOURCES) \
|
||||
@ -449,7 +453,8 @@ SRCONV_PROG = srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT)
|
||||
bin_SCRIPTS = @BUILD_INSTALL_MISC@
|
||||
EXTRA_SCRIPTS = embedspu
|
||||
BFDTEST1_PROG = bfdtest1
|
||||
TEST_PROGS = $(BFDTEST1_PROG)
|
||||
BFDTEST2_PROG = bfdtest2
|
||||
TEST_PROGS = $(BFDTEST1_PROG) $(BFDTEST2_PROG)
|
||||
RENAMED_PROGS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG)
|
||||
|
||||
# Stuff that goes in tooldir/ if appropriate.
|
||||
@ -545,6 +550,7 @@ readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
|
||||
bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
|
||||
bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
|
||||
LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
|
||||
size_SOURCES = size.c $(BULIBS)
|
||||
objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
|
||||
@ -721,6 +727,9 @@ ar$(EXEEXT): $(ar_OBJECTS) $(ar_DEPENDENCIES)
|
||||
bfdtest1$(EXEEXT): $(bfdtest1_OBJECTS) $(bfdtest1_DEPENDENCIES)
|
||||
@rm -f bfdtest1$(EXEEXT)
|
||||
$(LINK) $(bfdtest1_OBJECTS) $(bfdtest1_LDADD) $(LIBS)
|
||||
bfdtest2$(EXEEXT): $(bfdtest2_OBJECTS) $(bfdtest2_DEPENDENCIES)
|
||||
@rm -f bfdtest2$(EXEEXT)
|
||||
$(LINK) $(bfdtest2_OBJECTS) $(bfdtest2_LDADD) $(LIBS)
|
||||
coffdump$(EXEEXT): $(coffdump_OBJECTS) $(coffdump_DEPENDENCIES)
|
||||
@rm -f coffdump$(EXEEXT)
|
||||
$(LINK) $(coffdump_OBJECTS) $(coffdump_LDADD) $(LIBS)
|
||||
@ -842,6 +851,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arparse.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arsup.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bfdtest1.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bfdtest2.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bin2c.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binemul.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bucomm.Po@am__quote@
|
||||
|
106
binutils/bfdtest2.c
Normal file
106
binutils/bfdtest2.c
Normal file
@ -0,0 +1,106 @@
|
||||
/* A program to test BFD.
|
||||
Copyright 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Binutils.
|
||||
|
||||
This program 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 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,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
|
||||
static void
|
||||
die (const char *s)
|
||||
{
|
||||
printf ("oops: %s\n", s);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void *
|
||||
iovec_open (struct bfd *nbfd ATTRIBUTE_UNUSED, void *open_closure)
|
||||
{
|
||||
return open_closure;
|
||||
}
|
||||
|
||||
static file_ptr iovec_read (struct bfd *nbfd ATTRIBUTE_UNUSED,
|
||||
void *stream, void *buf, file_ptr nbytes,
|
||||
file_ptr offset)
|
||||
{
|
||||
FILE* file = (FILE*) stream;
|
||||
|
||||
if (fseek(file, offset, SEEK_SET) != 0)
|
||||
die ("fseek error");
|
||||
|
||||
return fread (buf, 1, nbytes, file);
|
||||
}
|
||||
|
||||
static int
|
||||
iovec_stat (struct bfd *abfd ATTRIBUTE_UNUSED,
|
||||
void *stream, struct stat *sb)
|
||||
{
|
||||
return fstat (fileno ((FILE*) stream), sb);
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
check_format_any (struct bfd *abfd, bfd_format format)
|
||||
{
|
||||
char** targets = NULL;
|
||||
|
||||
if (bfd_check_format_matches (abfd, format, &targets))
|
||||
return TRUE;
|
||||
|
||||
if (targets)
|
||||
{
|
||||
bfd_find_target (targets[0], abfd);
|
||||
|
||||
return bfd_check_format (abfd, format);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char** argv)
|
||||
{
|
||||
FILE* file;
|
||||
bfd *abfd, *mbfd;
|
||||
|
||||
if (argc < 2)
|
||||
die ("Usage: test archivefile");
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
if (!file)
|
||||
die ("file not found");
|
||||
|
||||
abfd = bfd_openr_iovec (argv[1], 0, iovec_open, file,
|
||||
iovec_read, NULL, iovec_stat);
|
||||
if (!abfd)
|
||||
die ("error opening file");
|
||||
|
||||
if (!check_format_any (abfd, bfd_archive))
|
||||
die ("not an archive");
|
||||
|
||||
mbfd = bfd_openr_next_archived_file (abfd, 0);
|
||||
if (!mbfd)
|
||||
die ("error opening archive member");
|
||||
|
||||
if (!bfd_close (mbfd))
|
||||
die ("error closing archive member");
|
||||
|
||||
if (!bfd_close (abfd))
|
||||
die ("error closing archive");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,3 +1,14 @@
|
||||
2012-11-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR binutils/14567
|
||||
* binutils-all/ar.exp (bfdtest1): Removed.
|
||||
(long_filenames): Take bfdtests.
|
||||
(thin_archive): Likewise.
|
||||
(thin_archive_with_nested): Likewise.
|
||||
(bfdtests): New.
|
||||
Pass $bfdtests to long_filenames, thin_archive and
|
||||
thin_archive_with_nested.
|
||||
|
||||
2012-10-29 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* binutils-all/copy-3.d: Exclude all cygwin and mingw targets,
|
||||
|
@ -27,16 +27,14 @@ if ![is_remote host] {
|
||||
}
|
||||
}
|
||||
|
||||
set bfdtest1 $base_dir/bfdtest1
|
||||
|
||||
# send_user "Version [binutil_version $AR]"
|
||||
|
||||
# Test long file name support
|
||||
|
||||
proc long_filenames { } {
|
||||
proc long_filenames { bfdtests } {
|
||||
global AR
|
||||
global host_triplet
|
||||
global bfdtest1
|
||||
global base_dir
|
||||
|
||||
set testname "ar long file names"
|
||||
|
||||
@ -126,11 +124,13 @@ proc long_filenames { } {
|
||||
return
|
||||
}
|
||||
|
||||
set exec_output [binutils_run $bfdtest1 "$dest"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname (bfdtest1)"
|
||||
return
|
||||
foreach bfdtest $bfdtests {
|
||||
set exec_output [binutils_run "$base_dir/$bfdtest" "$dest"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname ($bfdtest)"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
@ -227,13 +227,13 @@ proc symbol_table { } {
|
||||
|
||||
# Test building a thin archive.
|
||||
|
||||
proc thin_archive { } {
|
||||
proc thin_archive { bfdtests } {
|
||||
global AR
|
||||
global AS
|
||||
global NM
|
||||
global srcdir
|
||||
global subdir
|
||||
global bfdtest1
|
||||
global base_dir
|
||||
|
||||
set testname "ar thin archive"
|
||||
|
||||
@ -259,11 +259,13 @@ proc thin_archive { } {
|
||||
return
|
||||
}
|
||||
|
||||
set exec_output [binutils_run $bfdtest1 "$archive"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname (bfdtest1)"
|
||||
return
|
||||
foreach bfdtest $bfdtests {
|
||||
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname ($bfdtest)"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
set got [binutils_run $NM "--print-armap $archive"]
|
||||
@ -282,13 +284,13 @@ proc thin_archive { } {
|
||||
|
||||
# Test building a thin archive with a nested archive.
|
||||
|
||||
proc thin_archive_with_nested { } {
|
||||
proc thin_archive_with_nested { bfdtests } {
|
||||
global AR
|
||||
global AS
|
||||
global NM
|
||||
global srcdir
|
||||
global subdir
|
||||
global bfdtest1
|
||||
global base_dir
|
||||
|
||||
set testname "ar thin archive with nested archive"
|
||||
|
||||
@ -324,18 +326,20 @@ proc thin_archive_with_nested { } {
|
||||
return
|
||||
}
|
||||
|
||||
set exec_output [binutils_run $bfdtest1 "$archive"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname (bfdtest1)"
|
||||
return
|
||||
}
|
||||
foreach bfdtest $bfdtests {
|
||||
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname ($bfdtest)"
|
||||
return
|
||||
}
|
||||
|
||||
set exec_output [binutils_run $bfdtest1 "$archive2"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname (bfdtest1)"
|
||||
return
|
||||
set exec_output [binutils_run "$base_dir/$bfdtest" "$archive2"]
|
||||
if ![string match "" $exec_output] {
|
||||
verbose -log $exec_output
|
||||
fail "$testname ($bfdtest)"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
set got [binutils_run $NM "--print-armap $archive"]
|
||||
@ -554,10 +558,12 @@ proc move_an_element { } {
|
||||
|
||||
# Run the tests.
|
||||
|
||||
long_filenames
|
||||
set bfdtests [list bfdtest1 bfdtest2]
|
||||
|
||||
long_filenames $bfdtests
|
||||
symbol_table
|
||||
thin_archive
|
||||
thin_archive_with_nested
|
||||
thin_archive $bfdtests
|
||||
thin_archive_with_nested $bfdtests
|
||||
argument_parsing
|
||||
deterministic_archive
|
||||
delete_an_element
|
||||
|
Loading…
Reference in New Issue
Block a user