From 197245e341aeb1b5da8ee5fbe5d6c49de650fb89 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 30 Oct 2019 10:50:23 +0000 Subject: Add a --output= option to ar to allow the specifying of an output directory. * ar.c (emum long option numbers): Declare. Use to provide numerical values for long options. (long_options): Add --output option. (usage): Mention the --output option. (open_output_file): New function. Create a filepath for an output file and open it. (extract_file): Use open_output_file(). (open_output_file): * testsuite/binutils-all/ar.exp: Add a test of the new feature. * doc/binutils.texi: Document the new feature. * NEWS: Mention the new feature. --- binutils/testsuite/binutils-all/ar.exp | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'binutils/testsuite') diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp index bc1fbdb..c043f7e 100644 --- a/binutils/testsuite/binutils-all/ar.exp +++ b/binutils/testsuite/binutils-all/ar.exp @@ -605,6 +605,50 @@ proc empty_archive { } { pass $testname } +# Test extracting an element. + +proc extract_an_element { } { + global AR + global AS + global srcdir + global subdir + + set testname "ar extracting an element" + + if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] { + unresolved $testname + return + } + + set archive artest.a + + if [is_remote host] { + set objfile [remote_download host tmpdir/bintest.o] + remote_file host delete $archive + } else { + set objfile tmpdir/bintest.o + } + + remote_file build delete $archive + + set got [binutils_run $AR "-r -c $archive ${objfile}"] + if ![string match "" $got] { + fail $testname + return + } + + set got [binutils_run $AR "--output=tmpdir -x $archive ${objfile}"] + if ![string match "" $got] { + fail $testname + return + } + + remote_file build delete $archive + remote_file build delete tmpdir/$archive + + pass $testname +} + # Run the tests. # Only run the bfdtest checks if the programs exist. Since these @@ -625,6 +669,7 @@ deterministic_archive delete_an_element move_an_element empty_archive +extract_an_element if { [is_elf_format] && [supports_gnu_unique] } { unique_symbol -- cgit v1.1