RFC: Add STV_EXPORT (Re: PATCH: [4.1 Regression]: java compiler generates wrong code on ia64)

H. J. Lu hjl@lucon.org
Tue Apr 19 16:45:00 GMT 2005


On Mon, Apr 18, 2005 at 04:25:11PM -0400, Bryce McKinlay wrote:
> H. J. Lu wrote:
> 
> >On Mon, Apr 18, 2005 at 03:57:47PM -0400, Bryce McKinlay wrote:
> > 
> >
> >>>I am not familiar with Java semantics. targetm.binds_local_p will
> >>>tell you if a function may be discarded at the link time or overriden
> >>>by something else at the run time. If a function is public and defined
> >>>within the same compilation unit, it can be discarded at the link time
> >>>due to linkonce/comdat and can be overriden by dynamic linker. If it is
> >>>discarded or overriden, does a local alias make any more senses for
> >>>Java? It seems that
> >>>
> >>>if (DECL_EXTERNAL (method) || !targetm.binds_local_p (method))
> >>> return method;
> >>>
> >>>will make sure that an aliase will only be created when the function
> >>>is defined within the compilation unit and won't be discarded or
> >>>overriden.
> >>>
> >>>
> >>>     
> >>>
> >>Well, this is certainly the behaviour we would like for Java, but AFAIK 
> >>we have no way to ensure that something always binds locally.
> >>
> >>binds_local_p is described as:
> >>
> >>/* True if EXP names an object for which name resolution must resolve
> >>   to the current module.  */
> >>
> >>It seems to me that, given ELF semantics, a public symbol can always be 
> >>overriden by the linker at runtime, thus targetm.binds_local_p will 
> >>always be false? If there was some way to force targetm.binds_local_p 
> >>then we wouldn't need make_local_function_alias()!
> >>
> >>   
> >>
> >
> >
> >A public symbol can be overriden by the dynamic linker at runtime
> >unless it is internal, hidden or protected. If you don't need to export
> >it outside of the module, you can mark it hidden. If you have to export
> >it outside of the module, you can mark it protected.
> > 
> >
> 
> Currently, ALL the symbols for Java methods need to be visible outside 
> the module. This is because of both a) the need for compatibility with 
> the C++ ABI for CNI (CNI allows "private" Java methods to be called from 
> C++), and b) continued support for the "old" C++ ABI for Java code.
> 
> Using protected symbols everywhere would carry significant overhead, 
> apparently - see http://gcc.gnu.org/ml/java-patches/2005-q1/msg00201.html
> 

Should we consider adding another visibility, STV_EXPORT, for both
performance and correctness? It should be between STV_HIDDEN and
STV_PROTECTED. The main difference is we don't need to consider
function pointer comparison. The only difference between STV_HIDDEN and
STV_EXPORT is a STV_EXPORT will have a STB_GLOBAL entry in .dynsym.
STV_EXPORT can be used in both DSO and executable.

Another possibility is to allow linker version script to overwrite
hidden symbols. That is if a symbol is global in version script, we
export it even if it is marked hidden:

http://sourceware.org/ml/binutils/2005-03/msg00087.html


H.J.



More information about the Java-patches mailing list