I'm not sure I understand your reasoning here; I think you might be
misreading what the gABI says. Certainly, if we have a reference to a
protected or hidden symbol, by definition, we must have a definition
of that symbol somewhere within the same load module (what the gABI
refers to as a "component" -- i.e., an executable or a shared object).
It does not say that the definition must be provided within the same
translation unit (i.e., a relocatable object).
It's funny to me that after more than 15 years, suddenly protected
symbols and pre-emption seem to be such a hot topic. I'm curious why
-- what's going on that has brought this tiny little corner case to
such a head?
>> I'm not sure I understand your reasoning here; I think you might be
>> misreading what the gABI says. Certainly, if we have a reference to a
>> protected or hidden symbol, by definition, we must have a definition
>> of that symbol somewhere within the same load module (what the gABI
>> refers to as a "component" -- i.e., an executable or a shared object).
>> It does not say that the definition must be provided within the same
>> translation unit (i.e., a relocatable object).
>
> I'm talking about the component, not the translation unit. Why must a
> protected symbol be defined in the same component? It is exported after all.
I guess I still don't understand what you're getting at. It must be
defined in the same component because that's the *definition* of
"protected". If you drop that requirement, protected visibility means
nothing.
On 11-Apr-2016 11:54 PM, joerg.sonnenberger via Generic System V
> I'm talking about the component, not the translation unit. Why must a
> protected symbol be defined in the same component?
Because the protection should not interfere with other components (load
modules). For instance, a shared library might have its own
implementation of a memory allocator, and not use libc. Another shared
library linked to the same exe may need the libc allocator. In this
case, protection (and hence preemption) cannot be at the global exe
level. Unless you use techniques like RTLD_GROUP or shared library load
groups, which are non-standard (AFAIK).
> It is exported after
> all.
Its a side effect in a way. If you dont want, use STV_HIDDEN that would
eventually become STB_LOCAL.
> It seems quite strange that a code generator or assembler has to
> drop the visibility knowledge when creating a reference to something
> outside the current component, which it normally has no chance of knowing.
LTO should be able to handle this?
Based on the discussion, I tend to understand your requirement is to get
the optimizations of hidden references, but still get the visibility
outside so that other load modules can use the definition. Am I right?
To me it looks like a very corner case and falls under the category of
peep hole optimizations that compilers can handle through LTOs.
I cant think of any other use case as STV_HIDDEN and STV_PROTECTED have
well defined semantics and a good developer should know when to use what.
If you think my understanding is wrong, please consider explaining the
concerns with some simple code snippets? That would be very good and
helpful.
>> I'm not sure I understand your reasoning here; I think you might be
>> misreading what the gABI says. Certainly, if we have a reference to a
>> protected or hidden symbol, by definition, we must have a definition
>> of that symbol somewhere within the same load module (what the gABI
>> refers to as a "component" -- i.e., an executable or a shared object).
>> It does not say that the definition must be provided within the same
>> translation unit (i.e., a relocatable object).
>
> I'm talking about the component, not the translation unit. Why must a
> protected symbol be defined in the same component? It is exported after all.
I guess I still don't understand what you're getting at. It must be
defined in the same component because that's the *definition* of
"protected". If you drop that requirement, protected visibility means
nothing.
> It seems quite strange that a code generator or assembler has to drop the
> visibility knowledge when creating a reference to something outside the
> current component, which it normally has no chance of knowing.
Again, I don't understand. What do you mean by "drop the visibility knowledge"?
-cary
--
You received this message because you are subscribed to the Google Groups "Generic System V Application Binary Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to generic-abi...@googlegroups.com.
To post to this group, send email to gener...@googlegroups.com.
Visit this group at https://groups.google.com/group/generic-abi.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Generic System V Application Binary Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to generic-abi...@googlegroups.com.
To post to this group, send email to gener...@googlegroups.com.
Visit this group at https://groups.google.com/group/generic-abi.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Generic System V Application Binary Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to generic-abi...@googlegroups.com.
To post to this group, send email to gener...@googlegroups.com.
Visit this group at https://groups.google.com/group/generic-abi.
For more options, visit https://groups.google.com/d/optout.
Since readonly_str and writable_str are expected to be defined
locally at run-time, linker should set
NT_GNU_PROPERTY_NO_COPY_ON_PROTECTED on the
output shared obect....
NT_GNU_PROPERTY_NO_COPY_ON_PROTECTED applies to all
protected symbols.
If copy relocation is allowed on a symbol, it
shouldn't be made protected.
> We use the same information, but at present have chosen to let ldd(1)
> issue a diagnostic, rather than have ld.so.1() set a fatal error.
> If ld(1) can be instructed *not* to set this flag, then I question who would
> have the smarts to know whether to do this.
When this flag is set by compiler, there is no choice. If it isn't
set in input relocatable object files, ld has a choice. By default,
ld won't set it unless it is instructed otherwise at command line.
> If you really want to improve things, tell folks not to export data items in
> the first place - hide data behind function interfaces.
Or use GNU_PROPERTY_NO_COPY_ON_PROTECTED, which
I have updated to remove the "NT_" prefix.
> Now that PIE (position-independent executables) are on the horizon, perhaps
> we'll get lucky with their use and protected symbols. Future users might
> never
> have to know what a copy relocation was :-)
>
Well, GCC and binutils have been changed to generate copy relocation
in PIE :-).
Copy relocation can improve performance. Google enabled copy
relocations for PIE in ld/gold and GCC to improve prefomance by
up to 5%:
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01215.html