Bug 65846 - Optimize data access in PIE with copy reloc
Summary: Optimize data access in PIE with copy reloc
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2015-04-22 13:33 UTC by H.J. Lu
Modified: 2017-07-04 20:05 UTC (History)
1 user (show)

See Also:
Host:
Target: i386-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-04-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-04-22 13:33:49 UTC
With linker which supports copy relocation in PIE:

https://sourceware.org/bugzilla/show_bug.cgi?id=18289

For

extern int glob_a;
int foo ()
{
  return glob_a;
}

compiler can optimize it from

	call	__x86.get_pc_thunk.ax
	addl	$_GLOBAL_OFFSET_TABLE_, %eax
	movl	glob_a@GOT(%eax), %eax
	movl	(%eax), %eax
	ret

to

	call	__x86.get_pc_thunk.ax
	addl	$_GLOBAL_OFFSET_TABLE_, %eax
	movl	glob_a@GOTOFF(%eax), %eax
	ret
Comment 1 H.J. Lu 2015-04-22 16:36:33 UTC
A patch is posted at

https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01331.html
Comment 2 Jakub Jelinek 2016-04-27 10:58:15 UTC
GCC 6.1 has been released.
Comment 3 Jakub Jelinek 2016-12-21 10:58:26 UTC
GCC 6.3 is being released, adjusting target milestone.
Comment 4 Richard Biener 2017-07-04 08:49:25 UTC
GCC 6.4 is being released, adjusting target milestone.