Please use following shell commands to reproduce the problem: ``` # create subdirectory mkdir subdir # create source files with dummy functions echo 'void func1(){}' > file1.c echo 'void func2(){}' > ./subdir/file2.c # compiling sources into object files gcc -c file1.c -o file1.o gcc -c ./subdir/file2.c -o ./subdir/file2.o # creating "thin archive" file from object files ar crT out.a file1.o ./subdir/file2.o # running objcopy, which leads to an error objcopy out.a out_copy.a ``` As a result, following error occurs: ``` objcopy:st0AENRL/subdir/file2.o: No such file or directory ``` Problem with objcopy occurs when "thin" archive is composed of object files from subdirectories. P.S. Problem was also described on StackOverflow: https://stackoverflow.com/questions/54907402/problem-while-using-objcopy-with-thin-archive-file
Bug was reproduced on versions 2.26 and 2.32.
Hi lol lol, Hmm, you do realise that copying a thin library in this way is essentially the same thing as just copying it normally, right ? The question is, what would you expect objcopy to do if you also had one or more of its transformation options enabled as well. For example, what should this do: objcopy --strip-debug out.a out_copy.a Would you expect objcopy to create new versions of all of the object files linked to within out.a, with the debugging stripped from the new versions ? If so, what names should be given to these new object files ? Or how about: objcopy out.a subdir/copy.a Would you expect objcopy to leave the object files intact but to rename the links inside copy.a so that they are valid for the new location of the thin library ? It seems to me that the easiest thing to do would be to just reject attempts to objcopy thin archives. But maybe this is too draconian. Would you be happy if an in-place copy of a thin archive was allowed, but transformations, or relocations were refused ? Cheers Nick
Hi Nick, Q. Hmm, you do realise that copying a thin library in this way is essentially the same thing as just copying it normally, right? A. Yes. It was chosen for simplicity. Anyway, it shouldn't fail. Can you agree? Q. The question is, what would you expect objcopy to do if you also had one or more of its transformation options enabled as well. For example, what should this do: objcopy --strip-debug out.a out_copy.a A. I expect similar behavior as for other "non-thin" object files. Why not to do "--strip-debug" for all included files recursively? It may be done in-place, or done with a copy. Q. Would you expect objcopy to create new versions of all of the object files linked to within out.a, with the debugging stripped from the new versions ? If so, what names should be given to these new object files ? Or how about: objcopy out.a subdir/copy.a Would you expect objcopy to leave the object files intact but to rename the links inside copy.a so that they are valid for the new location of the thin library ? A. In this case (case, when objcopy pretends to change object files), we may simply notify user, that object files will be rewritten and wait for the confirmation. Q. It seems to me that the easiest thing to do would be to just reject attempts to objcopy thin archives. But maybe this is too draconian. Would you be happy if an in-place copy of a thin archive was allowed, but transformations, or relocations were refused? A. I think, it is not a bad idea to simply disallow objcopy for thin archives till the moment, when it will be supported (in alternative future). I think it is not of "draconian" attempt. This way, user of this magic tool will not be confused at all. Thank you! WBR, lol lol
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f5f20315116c43110c058ec9d787e20f901309f2 commit f5f20315116c43110c058ec9d787e20f901309f2 Author: Nick Clifton <nickc@redhat.com> Date: Mon Mar 4 13:11:08 2019 +0000 Stop objcopy from attempting to copy thin archives. PR 24281 * objcopy.c (copy_archive): Do not copy thin archives.
Hi lol lol, Great - in which case I have applied a patch to stop objcopy from copying thin archives - for now... Cheers Nick