When -Bsymbolic is passed to linker, references to global symbols
defined in the shared library are resolved locally. We should pass
-fsymbolic to GCC in this case.
* collect2.c (main): Add -fsymbolic to COLLECT_GCC_OPTIONS if
-Bsymbolic is used.
* doc/invoke.texi: Updated.
X86: Optimize access to globals in PIE with copy reloc
Normally, with PIE, GCC accesses globals that are extern to the module
using GOT. This is two instructions, one to get the address of the global
from GOT and the other to get the value. Examples:
---
extern int a_glob;
int
main ()
{
return a_glob;
}
---
With PIE, the generated code accesses global via GOT using two memory
loads:
Some experiments on google and SPEC CPU benchmarks show that the extra
instruction affects performance by 1% to 5%.
Solution - Copy Relocations:
When the linker supports copy relocations, GCC can always assume that
the global will be defined in the executable. For globals that are
truly extern (come from shared objects), the linker will create copy
relocations and have them defined in the executable. Result is that
no global access needs to go through GOT and hence improves performance.
We can generate
movl a_glob(%rip), %eax
for 64-bit and
movl a_glob@GOTOFF(%eax), %eax
for 32-bit. This optimization only applies to undefined non-weak
non-TLS global data. Undefined weak global or TLS data access still
must go through GOT.
This patch reverts legitimate_pic_address_disp_p change made in revision
218397, which only applies to x86-64. Instead, this patch updates
targetm.binds_local_p to indicate if undefined non-weak non-TLS global
data is defined locally in PIE. It also introduces a new target hook,
binds_tls_local_p to distinguish TLS variable from non-TLS variable. By
default, binds_tls_local_p is the same as binds_local_p which assumes
TLS variable.
This patch checks if 32-bit and 64-bit linkers support PIE with copy
reloc at configure time. 64-bit linker is enabled in binutils 2.25
and 32-bit linker is enabled in binutils 2.26. This optimization
is enabled only if the linker support is available.
Since copy relocation in PIE is incompatible with DSO created by
-Wl,-Bsymbolic, this patch also adds a new option, -fsymbolic, which
controls how references to global symbols are bound. The -fsymbolic
option binds references to global symbols to the local definitions
and external references globally. It avoids copy relocations in PIE
and optimizes global symbol references in shared library created
by -Wl,-Bsymbolic.
gcc/
PR target/65846
PR target/65886
* configure.ac (HAVE_LD_PIE_COPYRELOC): Renamed to ...
(HAVE_LD_X86_64_PIE_COPYRELOC): This.
(HAVE_LD_386_PIE_COPYRELOC): New. Defined to 1 if Linux/ia32
linker supports PIE with copy reloc.
* output.h (default_binds_tls_local_p): New.
(default_binds_local_p_3): Add 2 bool arguments.
* target.def (binds_tls_local_p): New target hook.
* varasm.c (decl_default_tls_model): Replace targetm.binds_local_p
with targetm.binds_tls_local_p.
(default_binds_local_p_3): Add a bool argument to indicate TLS
variable and a bool argument to indicate if an undefined non-TLS
non-weak data is local. Double check TLS variable. If an
undefined non-TLS non-weak data is local, treat it as defined
locally.
(default_binds_local_p): Pass true and false to
default_binds_local_p_3.
(default_binds_local_p_2): Likewise.
(default_binds_local_p_1): Likewise.
(default_binds_tls_local_p): New.
* config.in: Regenerated.
* configure: Likewise.
* doc/tm.texi: Likewise.
* config/i386/i386.c (legitimate_pic_address_disp_p): Don't
check HAVE_LD_PIE_COPYRELOC here.
(ix86_binds_local): New.
(ix86_binds_tls_local_p): Likewise.
(ix86_binds_local_p): Use it.
(TARGET_BINDS_TLS_LOCAL_P): New.
* doc/tm.texi.in (TARGET_BINDS_TLS_LOCAL_P): New hook.
* lib/target-supports.exp (check_effective_target_pie_copyreloc):
Check HAVE_LD_X86_64_PIE_COPYRELOC and HAVE_LD_386_PIE_COPYRELOC
instead of HAVE_LD_X86_64_PIE_COPYRELOC.
2f5441e...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Bob Duff <email address hidden>
* a-coinve.adb, a-contai.adb: Update comments.
* pprint.ads: Minor reformatting.
d3e59bb...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Philippe Gil <email address hidden>
* g-debpoo.ads (Dump): NEW print Debug_Pool statistics & main
contributors.
(Dump_Stdout): NEW print to stdout Debug_Pool statistics &
main contributors.
(Reset): NEW reset counters to 0.
(Get_Size): NEW return size allocated at parameter.
(High_Water_Mark): NEW.
(Current_Water_Mark): NEW.
(System_Memory_Debug_Pool): NEW tell Debug_Pools that
System.Memory uses it.
* g-debpoo.adb (Traceback_Htable_Elem): add Frees, Total_Frees
components.
(Find_Or_Create_Traceback): don't manage in System.Memory
Debug_Pool Deallocate Traceback's.
(Validity): add optional Handled table when System.Memory asked
for Allow_Unhandled_Memory.
(Allocate): handle Allocate reentrancy occuring when System.Memory
uses Debug_Pools.
(Deallocate): handle when Allow_Unhandled_Memory
is set deallocation of unhandled memory. Dont't check
Size_In_Storage_Elements if equal to Storage_Count'Last. update
Frees, Total_Frees new components.
0c0a0b2...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Vincent Celier <email address hidden>
* sem_cat.adb (Check_Categorization_Dependencies): Do nothing
when -gnatdu is specified.
2015-10-20 Ed Schonberg <email address hidden>
* sem_ch8.adb (analyze_Subprogram_Renaming): The actual for a
formal abstract subprogram must have a controlling type.
* stand.ads: Minor whitespace cleanup.
55ab526...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Gary Dismukes <email address hidden>
* sem_ch13.adb: Minor reference change (RM => AARM).
2015-10-20 Eric Botcazou <email address hidden>
* make.adb (Check): Skip multilib switches reinstated by the
compiler only when counting the number of switches, since it is
what really matters in the regular operating mode.
2015-10-20 Arnaud Charlet <email address hidden>
* einfo.adb: Add extra assertion for small clause.
* cstand.adb: Minor style fix in comment.
* debug.adb: Minor reformatting.
* exp_util.adb: Fix minor typo.
2015-10-20 Ed Schonberg <email address hidden>
* sem_ch12.adb (Same_Instantiated_Function): New predicate in
Check_Formal_Package_Instance, used to verify that the formal
and the actual of an actual package match when both are functions
given as attribute references.
078a74b...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Bob Duff <email address hidden>
* a-coinve.ads, a-coinve.adb: Do the same efficiency
improvements that were already done in the definite case
(Ada.Containers.Vectors, i.e. a-convec). This includes the
ability to suppress checks, the fast path for Append, inlining
as appropriate, and special-casing of "for ... of" loops. Reuse
the tampering machinery that is now in Ada.Containers. Simplify
many operations.
* a-convec.ads, a-convec.adb: Change the code to be more similar
to a-coinve.
* a-finali.ads, a-finali.adb: Expose the "null"-ness of the
operations. This may enable optimizations in the future, and
seems cleaner anyway.
2015-10-20 Ed Schonberg <email address hidden>
* sem_ch13.adb (Is_Operational_Item): Attributes related to
Ada 2012 iterators are operational items, and can be specified
on partial views.
* sem_prag.adb (Check_Usage): Update the calls to Usage_Error.
(Usage_Error): Remove formal parameter Item. Emit a clearer message
concerning a missing dependency item and place it on the related pragma.
2015-10-20 Bob Duff <email address hidden>
* debug.adb, expander.adb: Implement -gnatd.B switch, which
triggers a bug box when an abort_statement is seen. This is
useful for testing Comperr.Compiler_Abort.
* gnat1drv.adb: Trigger bug box on all exceptions other than
Unrecoverable_Error.
d1cd139...
by
charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-10-20 Thomas Quinot <email address hidden>
* Makefile.rtl: add the following...
* g-binenv.ads, g-binenv.adb: New unit providing runtime access
to bind time captured values ("bind environment")
* init.c: declare new global variable __gl_bind_env_addr.
* bindgen.ads, bindgen.adb (Set_Bind_Env): record a bind
environment key=value pair.
(Gen_Bind_Env_String): helper to produce the bind environment data
called in the binder generated file.
(Gen_Output_File_Ada): Call the above (Gen_Adainit): Set
__gl_bind_env_addr accordingly.
* switch-b.adb: Support for command line switch -V (user interface
to set a build environment key=value pair)
* bindusg.adb: Document the above
2015-10-20 Vincent Celier <email address hidden>
* sem_prag.adb (Analyse_Pragma: Pragma Pure): Do not set the
entity as Pure if Debug_Flag_U is set.