From sacadmin Mon Oct 23 09:06:10 2006
Received: from jurassic.eng.sun.com (jurassic.SFBay.Sun.COM [129.146.106.105])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id k9NG6ALD005640
	for <psarc@sac.sfbay.sun.com>; Mon, 23 Oct 2006 09:06:10 -0700 (PDT)
Received: from [192.9.61.2] (punchin-rie.SFBay.Sun.COM [192.9.61.2])
	by jurassic.eng.sun.com (8.13.8+Sun/8.13.8) with ESMTP id k9NG693s403999;
	Mon, 23 Oct 2006 09:06:09 -0700 (PDT)
Message-ID: <453CE86E.2070405@Sun.com>
Date: Mon, 23 Oct 2006 09:06:06 -0700
From: Rod Evans <Rod.Evans@Sun.com>
Reply-To: Rod.Evans@Sun.com
Organization: Sun Microsystems Inc.
User-Agent: Thunderbird 1.5.0.5 (X11/20060814)
MIME-Version: 1.0
To: psarc@sac.sfbay.sun.com
CC: Ali Bahrami <Ali.Bahrami@Sun.com>, Sheldon Lobo <Sheldon.Lobo@Sun.com>,
        raj.prakash@Sun.com
Subject: 2006/595 link-editor support library interface - ld_open()
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Status: RO
Content-Length: 4856

I'm sponsoring the following case for myself.   This case qualifies for
Architectural self-review, but I wish to record the following
information.

------------------------------------------------------------------------
New interfaces, ld_open() and ld_open64, are being added to the
link-editor support library interfaces (ld_support(3EXT)).

This interface allows the support library to assign a new file
descriptor and/or assign a new ELF descriptor and/or assign a new
name, to an input file.

This flexibility is required by the Compiler Annotations by default
project, and is captured under 6479848.

------------------------------------------------------------------------

The Linker and Libraries Manual will be updated as follows:

ld_open()

     This function is called for each file input to the link-edit. This
     function, which was added in version LD_SUP_VERSION3, provides greater
     flexibility than the ld_file() function. This function allows the support
     library to replace the file descriptor, ELF descriptor, together with the
     associated file names. This function provides the following possible usage
     scenarios.

         .   The addition of new sections to an existing ELF file. In this case,
             the original ELF descriptor should be replaced with a descriptor
             that allows the ELF file to be updated. See the ELF_C_RDWR argument
             of elf_begin(3ELF).

         .   The entire input file can be replaced with an alternative. In this
             case, the original file descriptor and ELF descriptor should be
             replaced with descriptors that are associated with the new file.

     In both scenarios the path name and file name can be replaced with
     alternative names that indicate the input file has been modified.

     void ld_open(const char ** pname, const char ** fname, int * fd,
     	int flags, Elf ** elf, Elf * ref, size_t off, Elf_Kind kind);
     void ld_open64(const char ** pname, const char ** fname, int * fd,
     	int flags, Elf ** elf, Elf * ref, size_t off, Elf_Kind kind);

     pname is the path name of the input file about to be processed. fname is the
     file name of the input file about to be processed. fname is typically the
     base name of the pname. Both pname and fname can be modified by the support
     library.

     fd is the file descriptor of the input file. This descriptor can be closed
     by the support library, and a new file descriptor can be returned to the
     link-editor. A file descripter with the value -1 can be returned to indicate
     that the file should be ignored.

     The flags field indicates how the link-editor obtained the file. This field
     can be one or more of the following definitions:

         .  LD_SUP_DERIVED - The file name was not explicitly named on the
            command line. The file was derived from a -l expansion. Or, the file
            identifies an extracted archive member.

         .  LD_SUP_EXTRACTED - The file was extracted from an archive.

         .  LD_SUP_INHERITED - The file was obtained as a dependency of a
            command-line shared object.

     If no flags values are specified, then the input file has been explicitly
     named on the command line.

     elf is the ELF descriptor of the input file. This descriptor can be closed
     by the support library, and a new ELF descriptor can be returned to the
     link-editor. An ELF descripter with the value 0 can be returned to indicate
     that the file should be ignored. When the elf descriptor is associated with
     a member of an archive library, the ref descriptor is the ELF descriptor of
     the underlying archive file. The off represents the offset of the archive
     member within the archive file.

     kind indicates the input file type, which is either ELF_K_AR, or ELF_K_ELF,
     as defined in libelf.h


The ld_support(3EXT) man page will be updated as follows:


   Extended Library Functions                       ld_support(3EXT)

   NAME
      ld_support,  ld_atexit,  ld_atexit64,  ld_file,   ld_file64,
      ld_input_done,     ld_input_section,     ld_input_section64,
      ld_open,  ld_open64,  ld_section,  ld_section64,   ld_start,   |
      ...
      void ld_open(const char **pname,  const  char  **fname,  int   |
      *fd,  int  flags,  Elf **elf, Elf *ref, size_t off, Elf_kind   |
      kind);                                                         |

      void ld_open64(const char **pname, const char  **fname,  int   |
      *fd,  int  flags,  Elf **elf, Elf *ref, size_t off, Elf_kind   |
      kind);                                                         |
      ...

------------------------------------------------------------------------
Release Binding:               Patch/Micro
ld_open()/ld_open64:           Committed


-- 
Rod

