java/5487: arm-linux-gcj cross-compiler generates bad assembler-code

jsantala@tml.hut.fi jsantala@tml.hut.fi
Fri Jan 25 01:46:00 GMT 2002


>Number:         5487
>Category:       java
>Synopsis:       arm-linux-gcj cross-compiler generates bad assembler-code
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 25 01:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jukka Santala
>Release:        3.1 20020122 (experimental)
>Organization:
>Environment:
Using Red Hat 7.1, with GCC compiled as arm-linux cross-compiler.
>Description:
Compiling specific Java file of the Red Hat GCJ/rhug tree:
arm-linux-gcj -fCLASSPATH=upstream/src:./upstream/src -O2 -save-temps -dp -v --encoding=8859_1 -fassume-compiled -O2 -c upstream/src/org/apache/xerces/validators/dtd/DTDGrammar.java -MT upstream/src/org/apache/xerces/validators/dtd/lib_org_apache_xerces_la-DTDGrammar.lo -MD -MP -MF upstream/src/org/apache/xerces/validators/dtd/.deps/lib_org_apache_xerces_la-DTDGrammar.TPlo  -fPIC  -o upstream/src/org/apache/xerces/validators/dtd/.libs/lib_org_apache_xerces_la-DTDGrammar.lo

Using arm-linux-gcc cross-compiler, GCJ generates object-files with undefined symbol references. For example:
/home/jsantala/rhug-clean/xerces/.libs/lib-org-apache-xerces.so: undefined reference to `.L153'
/home/jsantala/rhug-clean/xerces/.libs/lib-org-apache-xerces.so: undefined reference to `.L156'
nm output of affected source module:
         U .L153
         U .L156
000000d8 d _CD_org_apache_xerces_validators_dtd_DTDGrammar
...
>From assembler source:
...
.L164:
        bl      _Jv_ThrowBadArrayIndex(PLT)     @ 855   *call_value_symbol/1
[length = 4]
        .align  2
.L155:
        b       .L156
        b       .L156
        b       .L156
        b       .L156
        b       .L156
        b       .L156
        b       .L153
.L166:
        ldr     r3, .L169+20    @ 1003  pic_load_addr_arm       [length = 4]
...

If compiler is ran with -fverbose-asm, it crashes with segmentation fault ICE:
gcc version 3.1 20020122 (experimental)
 /skiff/local/lib/gcc-lib/arm-linux/3.1/jc1 upstream/src/org/apache/xerces/validators/dtd/DTDGrammar.java -fuse-divide-subroutine -fuse-boehm-gc -fnon-call-exceptions -fkeep-inline-functions -quiet -dumpbase DTDGrammar.java -dp -O2 -O2 -version -fCLASSPATH=upstream/src:./upstream/src -fverbose-asm -fencoding=8859_1 -fassume-compiled -fPIC -MD -MT upstream/src/org/apache/xerces/validators/dtd/lib_org_apache_xerces_la-DTDGrammar.lo -MF upstream/src/org/apache/xerces/validators/dtd/.deps/lib_org_apache_xerces_la-DTDGrammar.TPlo -o DTDGrammar.s
GNU Java version 3.1 20020122 (experimental) (arm-linux)
        compiled by GNU C version 3.0.3.
Class path starts here:
    upstream/src/
    ./upstream/src/
    ./
    /skiff/local/share/libgcj.jar/ (system) (zip)
upstream/src/org/apache/xerces/validators/dtd/DTDGrammar.java:174: internal error: Segmentation fault
(gdb) where
#0  get_mem_expr_from_op (op=0x0, paddressp=0xbfffef98)
    at ../../gcc/gcc/final.c:3016
#1  0x08127f09 in output_asm_operand_names (operands=0xbffff1b0,
    oporder=0xbffff050, nops=1) at ../../gcc/gcc/final.c:3061
#2  0x08128053 in output_asm_insn (
    template=0xbffff110 "ldm%?%d0fd\t%|sp!, {%|r4, %|r5, %|r6, %|r7, %|r8, %|r9, %|sl, %|pc}", operands=0xbffff1b0) at ../../gcc/gcc/final.c:3289
#3  0x0822130b in output_return_instruction (operand=0x0, really_return=1,
    reverse=0) at ../../gcc/gcc/config/arm/arm.c:7353
#4  0x0816eeed in output_259 (operands=0x83623c0, insn=0x4039a640)
    at insn-output.c:1325
#5  0x08126cc4 in get_insn_template (code=259, insn=0x4039a640)
    at ../../gcc/gcc/final.c:1809
#6  0x0812701c in final_scan_insn (insn=0x4039a640, file=0x8385d88,
    optimize=2, prescan=0, nopeepholes=0) at ../../gcc/gcc/final.c:2591
#7  0x08126c0a in final (first=0x40396580, file=0x8385d88, optimize=2,
    prescan=0) at ../../gcc/gcc/final.c:1787
#8  0x081f78b4 in rest_of_compilation (decl=0x401c1d98)
    at ../../gcc/gcc/toplev.c:3464
#9  0x08063d94 in source_end_java_method () at ../../gcc/gcc/java/parse.y:7457
#10 0x08065ab1 in java_expand_method_bodies (class=0x401ba6cc)
    at ../../gcc/gcc/java/parse.y:8133
...

File DTDGramma.java from Apache-XML Xerces-Java project attached. Linking passes with -O0, but not with -O1 or -O2
>How-To-Repeat:
arm-linux-gcj -fCLASSPATH=upstream/src:./upstream/src -O2 -save-temps -dp -v --encoding=8859_1 -fassume-compiled -O2 -c upstream/src/org/apache/xerces/validators/dtd/DTDGrammar.java -MT upstream/src/org/apache/xerces/validators/dtd/lib_org_apache_xerces_la-DTDGrammar.lo -MD -MP -MF upstream/src/org/apache/xerces/validators/dtd/.deps/lib_org_apache_xerces_la-DTDGrammar.TPlo  -fPIC  -o upstream/src/org/apache/xerces/validators/dtd/.libs/lib_org_apache_xerces_la-DTDGrammar.lo

Have not tried to minimize test-case yet.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-java; name="DTDGrammar.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="DTDGrammar.java"

LyoKICogVGhlIEFwYWNoZSBTb2Z0d2FyZSBMaWNlbnNlLCBWZXJzaW9uIDEuMQogKgogKgogKiBD
b3B5cmlnaHQgKGMpIDIwMDAgVGhlIEFwYWNoZSBTb2Z0d2FyZSBGb3VuZGF0aW9uLiAgQWxsIHJp
Z2h0cyAKICogcmVzZXJ2ZWQuCiAqCiAqIFJlZGlzdHJpYnV0aW9uIGFuZCB1c2UgaW4gc291cmNl
IGFuZCBiaW5hcnkgZm9ybXMsIHdpdGggb3Igd2l0aG91dAogKiBtb2RpZmljYXRpb24sIGFyZSBw
ZXJtaXR0ZWQgcHJvdmlkZWQgdGhhdCB0aGUgZm9sbG93aW5nIGNvbmRpdGlvbnMKICogYXJlIG1l
dDoKICoKICogMS4gUmV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lvbiB0byBwdXQgaW50byBncmFtbWFyIGRvY3VtZW50
LgogICAgICAgIGZDdXJyZW50RWxlbWVudC5hcHBlbmRDaGlsZChlbGVtZW50RGVjbEVsZW1lbnQp
OwoKICAgICAgICAvLyBjcmVhdGUgZWxlbWVudCBkZWNsCiAgICAgICAgaW50IGVsZW1lbnREZWNs
SW5kZXggPSBjcmVhdGVFbGVtZW50RGVjbCgpOwoKICAgICAgICAvLyBzZXQgZWxlbWVudCBkZWNs
IHZhbHVlcwogICAgICAgIGZFbGVtZW50RGVjbC5jbGVhcigpOwogICAgICAgIGZFbGVtZW50RGVj
bC5uYW1lLnNldFZhbHVlcyhlbGVtZW50RGVjbCk7CiAgICAgICAgZkVsZW1lbnREZWNsLnR5cGUg
PSBjb250ZW50U3BlY1R5cGU7CiAgICAgICAgZkVsZW1lbnREZWNsLmNvbnRlbnRTcGVjSW5kZXgg
PSBjb250ZW50U3BlYzsKICAgICAgICBzZXRFbGVtZW50RGVjbChlbGVtZW50RGVjbEluZGV4LCBm
RWxlbWVudERlY2wpOwogICAgICAgIAogICAgICAgIGludCBjaHVuayA9IGVsZW1lbnREZWNsSW5k
ZXggPj4gQ0hVTktfU0hJRlQ7CiAgICAgICAgaW50IGluZGV4ID0gZWxlbWVudERlY2xJbmRleCAm
IENIVU5LX01BU0s7CiAgICAgICAgZW5zdXJlRWxlbWVudERlY2xDYXBhY2l0eShjaHVuayk7CiAg
ICAgICAgZkVsZW1lbnREZWNsSXNFeHRlcm5hbFtjaHVua11baW5kZXhdID0gaXNFeHRlcm5hbD8g
MSA6IDA7CgogICAgICAgIC8vIHJldHVybiBpbmRleAogICAgICAgIHJldHVybiBlbGVtZW50RGVj
bEluZGV4OwoKICAgIH0gLy8gYWRkRWxlbWVudERlY2woUU5hbWUsaW50LGludCk6aW50CgogICAg
cHJvdGVjdGVkIHZvaWQgcHV0RWxlbWVudE5hbWVNYXBwaW5nKFFOYW1lIG5hbWUsIGludCBzY29w
ZSwKICAgICAgICAgICA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XBl
IG9mIFhNTENvbnRlbnRTcGVjIHRvIGNyZWF0ZSAtIGZyb20gWE1MQ29udGVudFNwZWMuQ09OVEVO
VFNQRUNOT0RFXyoKICAgICAqIEBwYXJhbSBsZWZ0Tm9kZUluZGV4IGhhbmRsZSB0byBhbiBYTUxD
b250ZW50U3BlYwogICAgICogQHBhcmFtIHJpZ2h0Tm9kZUluZGV4IGhhbmRsZSB0byBhbiBYTUxD
b250ZW50U3BlYwogICAgICogQHJldHVybiBoYW5kbGUgdG8gdGhlIG5ld2x5IGNyZWF0ZSBYTUxD
b250ZW50U3BlYwogICAgICogQGV4Y2VwdGlvbiBqYXZhLmxhbmcuRXhjZXB0aW9uCiAgICAgKi8K
ICAgIHB1YmxpYyBpbnQgYWRkQ29udGVudFNwZWNOb2RlKGludCBub2RlVHlwZSwgCiAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgbGVmdE5vZGVJbmRleCwgCiAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICBpbnQgcmlnaHROb2RlSW5kZXgpIHRocm93cyBFeGNlcHRp
b24gewoKICAgICAgICAvLyBjcmVhdGUgY29udGVudCBzcGVjIG5vZGUKICAgICAgICBpbnQgY29u
dGVudFNwZWNJbmRleCA9IGNyZWF0ZUNvbnRlbnRTcGVjKCk7CgogICAgICAgIC8vIHNldCBjb250
ZW50IHNwZWMgbm9kZSB2YWx1ZXMKICAgICAgICBmQ29udGVudFNwZWMuc2V0VmFsdWVzKG5vZGVU
eXBlLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZnROb2RlSW5kZXgsIHJpZ2h0
Tm9kZUluZGV4KTsKICAgICAgICBzZXRDb250ZW50U3BlYyhjb250ZW50U3BlY0luZGV4LCBmQ29u
dGVudFNwZWMpOwoKICAgICAgICAvLyByZXR1cm4gaW5kZXggCiAgICAgICAgcmV0dXJuIGNvbnRl
bnRTcGVjSW5kZXg7CgogICAgfSAvLyBhZGRDb250ZW50U3Bl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bmdQb29sLnRvU3RyaW5nKHBpRGF0YSkpOwogICAgICAg
IGZDdXJyZW50RWxlbWVudC5hcHBlbmRDaGlsZChwaSk7CgogICAgfSAvLyBjYWxsUHJvY2Vzc2lu
Z0luc3RydWN0aW9uKGludCxpbnQpCgogICAgLy8gZGVwcmVjYXRlZCAtLSByZW1vdmVkIGZyb20g
RE9NIExldmVsIDIKCiAgICAvKioKICAgICAqIFN1cHBvcnRzIERPTSBMZXZlbCAyIGludGVybmFs
U3Vic2V0IGFkZGl0aW9ucy4KICAgICAqIENhbGxlZCB3aGVuIHRoZSBpbnRlcm5hbCBzdWJzZXQg
aXMgY29tcGxldGVseSBzY2FubmVkLgogICAgICovCiAgICBwdWJsaWMgdm9pZCBpbnRlcm5hbFN1
YnNldChpbnQgaW50ZXJuYWxTdWJzZXQpIHRocm93cyBFeGNlcHRpb24gewogICAgfQoKICAgIHBy
b3RlY3RlZCBib29sZWFuIGlzRFREKCkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgfQoKICAg
IC8vCiAgICAvLyBQcml2YXRlIG1ldGhvZHMKICAgIC8vCgogICAgLy8gZW5zdXJlIGNhcGFjaXR5
CgogICAgLyoqIEVuc3VyZXMgc3RvcmFnZSBmb3IgZWxlbWVudCBkZWNsYXJhdGlvbiBtYXBwaW5n
cy4gKi8KICAgIHByaXZhdGUgdm9pZCBlbnN1cmVFbGVtZW50RGVjbENhcGFjaXR5KGludCBjaHVu
aykgewogICAgICAgIGlmIChjaHVuayA+PSBmRWxlbWVudERlY2xNYXAubGVuZ3RoKSB7CiAgICAg
ICAgICAgIGZFbGVtZW50RGVjbE1hcCA9IHJlc2l6ZShmRWxlbWVudERlY2xNYXAsIAogICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZkVsZW1lbnREZWNsTWFwLmxlbmd0aCAqIDIp
OwogICAgICAgICAgICBmRWxlbWVudERlY2xJc0V4dGVybmFsID0gcmVzaXplKGZFbGVtZW50RGVj
bElzRXh0ZXJuYWwsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZkVsZW1l
bnREZWNsSXNFeHRlcm5hbC5sZW5ndGggKiAyKTsKICAgICAgICB9IGVsc2UgaWYgKGZFbGVtZW50
RGVjbE1hcFtjaHVua10gIT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQog
ICAgICAgIGZFbGVtZW50RGVjbE1hcFtjaHVua10gPSBuZXcgaW50W0NIVU5LX1NJWkVdOwogICAg
ICAgIGZFbGVtZW50RGVjbElzRXh0ZXJuYWxbY2h1bmtdID0gbmV3IGludFtDSFVOS19TSVpFXTsK
ICAgIH0KCiAgICAvKiogRW5zdXJlcyBzdG9yYWdlIGZvciBhdHRyaWJ1dGUgZGVjbGFyYXRpb24g
bWFwcGluZ3MuICovCiAgICBwcml2YXRlIHZvaWQgZW5zdXJlQXR0cmlidXRlRGVjbENhcGFjaXR5
KGludCBjaHVuaykgewogICAgICAgIGlmIChjaHVuayA+PSBmQXR0cmlidXRlRGVjbE1hcC5sZW5n
dGgpIHsKICAgICAgICAgICAgZkF0dHJpYnV0ZURlY2xNYXAgPSByZXNpemUoZkF0dHJpYnV0ZURl
Y2xNYXAsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmQXR0cmlidXRl
RGVjbE1hcC5sZW5ndGggKiAyKTsKICAgICAgICAgICAgZkF0dHJpYnV0ZURlY2xJc0V4dGVybmFs
ID0gcmVzaXplKGZBdHRyaWJ1dGVEZWNsSXNFeHRlcm5hbCwgCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgIGZBdHRyaWJ1dGVEZWNsSXNFeHRlcm5hbC5sZW5ndGggKiAyKTsK
ICAgICAgICB9IGVsc2UgaWYgKGZBdHRyaWJ1dGVEZWNsTWFwW2NodW5rXSAhPSBudWxsKSB7CiAg
ICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZkF0dHJpYnV0ZURlY2xNYXBbY2h1
bmtdID0gbmV3IGludFtDSFVOS19TSVpFXTsKICAgICAgICBmQXR0cmlidXRlRGVjbElzRXh0ZXJu
YWxbY2h1bmtdID0gbmV3IGludFtDSFVOS19TSVpFXTsKICAgIH0KCiAgICAvKiogRW5zdXJlcyBz
dG9yYWdlIGZvciBjb250ZW50IHNwZWMgbWFwcGluZ3MuICovCiAgICBwcml2YXRlIHZvaWQgZW5z
dXJlQ29udGVudFNwZWNDYXBhY2l0eShpbnQgY2h1bmspIHsKICAgICAgICBpZiAoY2h1bmsgPj0g
ZkNvbnRlbnRTcGVjTWFwLmxlbmd0aCkgewogICAgICAgICAgICBmQ29udGVudFNwZWNNYXAgPSBy
ZXNpemUoZkNvbnRlbnRTcGVjTWFwLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgIGZDb250ZW50U3BlY01hcC5sZW5ndGggKiAyKTsKICAgICAgICB9IGVsc2UgaWYgKGZDb250
ZW50U3BlY01hcFtjaHVua10gIT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAg
fQogICAgICAgIGZDb250ZW50U3BlY01hcFtjaHVua10gPSBuZXcgaW50W0NIVU5LX1NJWkVdOwog
ICAgfQoKICAgIC8vIHJlc2l6ZSBpbml0aWFsIGNodW5rCgogICAgLyoqIFJlc2l6ZXMgY2h1bmtl
ZCBpbnRlZ2VyIGFycmF5cy4gKi8KICAgIHByaXZhdGUgaW50W11bXSByZXNpemUoaW50IGFycmF5
W11bXSwgaW50IG5ld3NpemUpIHsKICAgICAgICBpbnQgbmV3YXJyYXlbXVtdID0gbmV3IGludFtu
ZXdzaXplXVtdOwogICAgICAgIFN5c3RlbS5hcnJheWNvcHkoYXJyYXksIDAsIG5ld2FycmF5LCAw
LCBhcnJheS5sZW5ndGgpOwogICAgICAgIHJldHVybiBuZXdhcnJheTsKICAgIH0KCn0gLy8gY2xh
c3MgRFRER3JhbW1hcgo=



More information about the Java-prs mailing list