User account creation filtered due to spam.

Bug 14813 - [3.4/4.0 Regression] The wrong init order
Summary: [3.4/4.0 Regression] The wrong init order
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2004-04-01 19:58 UTC by H.J. Lu
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: ia64-unknown-linux-gnu
Target: ia64-unknown-linux-gnu
Build: ia64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
A testcase (655 bytes, application/octet-stream)
2004-04-01 20:00 UTC, H.J. Lu
Details
A patch (468 bytes, patch)
2004-04-01 21:05 UTC, H.J. Lu
Details | Diff
An updated patch (467 bytes, patch)
2004-04-12 23:06 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2004-04-01 19:58:36 UTC
The change in crtend.asm causes the wrong init oder.
Comment 1 H.J. Lu 2004-04-01 20:00:44 UTC
Created attachment 6025 [details]
A testcase

# make
/usr/gcc-3.4/bin/gcc -O -g   -c -o bar.o bar.c
/usr/gcc-3.4/bin/gcc -static  bar.o   -o bar
./bar
preinit array 0
preinit array 1
preinit array 2
init array 0
init array 1
init array 2
init
fini array 2
fini array 1
fini array 0
fini

The right one should be

[hjl@gnu-4 init]$ make CC=gcc
gcc -O -g   -c -o bar.o bar.c
/tmp/ccyDlcv7.s: Assembler messages:
/tmp/ccyDlcv7.s:184: Warning: ignoring incorrect section type for
.preinit_array/tmp/ccyDlcv7.s:292: Warning: ignoring incorrect section type for
.init_array
/tmp/ccyDlcv7.s:400: Warning: ignoring incorrect section type for .fini_array
gcc -static  bar.o   -o bar
./bar
preinit array 0
preinit array 1
preinit array 2
init
init array 0
init array 1
init array 2
fini array 2
fini array 1
fini array 0
fini
Comment 2 Andrew Pinski 2004-04-01 20:05:28 UTC
The last change to crtend.asm was over a year ago why was this not found way before the release?
Comment 3 H.J. Lu 2004-04-01 21:05:51 UTC
Created attachment 6026 [details]
A patch

This patch should work for both 3.4 and 3.5.
Comment 4 Jakub Jelinek 2004-04-06 09:42:23 UTC
H.J., can you please post your patches to gcc-patches and put URL into
gcc-patches archive into the PRs instead of just attaching them to PRs and
not mentioning them on gcc-patches at all?

Comment 5 H.J. Lu 2004-04-06 18:09:21 UTC
The bug was introduced by

http://gcc.gnu.org/ml/gcc-cvs/2003-05/msg00274.html
Comment 6 H.J. Lu 2004-04-12 23:06:56 UTC
Created attachment 6080 [details]
An updated patch

__do_jv_register_classes should be place before
__do_global_ctors_aux to preserve the init order
the same as gcc 3.3.
Comment 7 H.J. Lu 2004-04-13 16:48:57 UTC
A testcase is posted at

http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00788.html
Comment 8 Jim Wilson 2004-04-21 22:37:59 UTC
Subject: Re:  [3.4/3.5 Regression] The wrong init order

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-01 20:05 -------
> The last change to crtend.asm was over a year ago why was this not found way before the release?

This only fails if an application or library uses init_array/fini_array.

GCC still uses ctors/dtors sections instead of the preferred and 
standardized init_array/fini_array sections.  So the only way that you 
can trigger this problem is if someone explicitly uses attribute section 
init_array, or if you link with code compiled by another compiler.

I suspect the latter method is how HJ found the problem, e.g. he may 
have noticed the problem after trying to link icc compiled code with 
gcc compiled code.
Comment 9 CVS Commits 2004-04-21 23:19:22 UTC
Subject: Bug 14813

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	hjl@gcc.gnu.org	2004-04-21 23:19:09

Modified files:
	gcc            : ChangeLog 
	gcc/config/ia64: crtbegin.asm crtend.asm 

Log message:
	2004-04-21  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR target/14813
	Backport from mainline:
	
	* config/ia64/crtend.asm: Move pointer to __do_global_ctors_aux
	in .init_array section to ...
	* config/ia64/crtbegin.asm: Here.
	
	* config/ia64/crtend.asm: Mark __do_global_ctors_aux global
	and hidden if HAVE_INITFINI_ARRAY is defined.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.405&r2=2.2326.2.406
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/crtbegin.asm.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.16&r2=1.16.16.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/crtend.asm.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.12&r2=1.12.16.1

Comment 10 Andrew Pinski 2004-04-21 23:22:04 UTC
Fixed for 3.4.1.