Add plugin_input_file_t
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 5 Feb 2015 13:00:52 +0000 (05:00 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 5 Feb 2015 13:03:07 +0000 (05:03 -0800)
commitf4b78d1898203363e7f551497b6231d0f891d6f9
tree7a6314e539a6952c9b100fc76c16735427de4b5c
parent7cc78d0780858b2f4a76c2867351cbfbb339c327
Add plugin_input_file_t

This patchs adds plugin_input_file_t to implement get_input_file, get_view
and release_input_file.  The maximum memeory overhead per IR input file
are about 40 bytes for plugin_input_file_t plus the memory to store input
IR filename.  According to

http://gcc.gnu.org/wiki/whopr/driver

RELEASE_INPUT_FILE: Function pointer to the linker interface that
releases a file descriptor for a claimed input file. The plug-in library
must call this interface for each file descriptor obtained by the "get
input file" interface. It must release all such file descriptors before
returning from the WPA phase.

However, GCC plug-in library doesn't use the "get input file" interface.
It processed the IR input in the claim file handler.  Since the the file
descriptor opened for the IR input was unused after the claim file
handler returns and GCC plug-in library before GCC 5 doesn't call the
RELEASE_INPUT_FILE function pointer, ld closed the file descriptor to
avoid leaking file descriptor.  But this approach doesn't work with
other plug-in libraries which uses the "get input file", "get view" and
"release input file" interfaces.  To avoid file descriptor leak with
GCC prior to GCC 5 and support other plug-in libraries at the same time,
we close the file descriptor only if the input IR file is a bfd_object
file.  This scheme doesn't work when a plug-in library needs the file
descriptor and its IR is stored in bfd_object file.

PR ld/17878
* plugin.c: Include <errno.h>.
(errno): New.  Declare if needed.
(plugin_input_file_t): New.
(get_input_file): Implemented.
(get_view): Likewise.
(release_input_file): Likewise.
(add_symbols): Updated.
(get_symbols): Likewise.
(plugin_maybe_claim): Allocate a plugin_input_file_t.  Close fd
only for a bfd_object input.
ld/ChangeLog
ld/plugin.c
This page took 0.026293 seconds and 4 git commands to generate.