PATCH RFA: Permit objcopy -add-section to work with /dev/null
Nick Clifton
nickc@redhat.com
Wed Jan 20 11:14:00 GMT 2010
Hi Ian,
> + /* We don't use get_file_size so that we can do
> + --add-section .note.GNU_stack=/dev/null
> + get_file_size doesn't work on /dev/null. */
You know this worries me a bit. If we do not check for ordinary files
then the user could be tripped up if they accidentally specify some
special file. Apart from /dev/null I cannot think of any other file
that they might reasonably want to use.
Plus you are using /dev/null as a shorthand for creating an empty file
and referring to that. Maybe it would just be simpler to enhance the
--add-section option so that if no filename is specified an empty
section is created. Ie:
--add-section .note.GNU_stack
creates an empty .note.GNU_stack section and:
--add-section .note.GNU_stack=foo.note
creates a .note.GNU_stack section containing a copy of the contents of
the foo.note file.
> First, it fails because objcopy silently fails when --add-section is
> used with a zero length file:
>
> size = get_file_size (s + 1);
> if (size < 1)
> {
> status = 1;
> break;
> }
>
> That just seems like an obvious bug.
Well I would agree that the silently failing is a bug. Generating a
warning message but continuing would probably be a more appropriate action.
Cheers
Nick
More information about the Binutils
mailing list