gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] Linking order oddity


From: john o goyo
Subject: [Gm2] Linking order oddity
Date: Tue, 30 Dec 2008 18:32:57 -0500

The order specified on the command line seems to determine
whether or not certain libraries are linked.  Witness the
following session (gm2-2008-12-15 on Solaris 10/sparc).

decus: 1750 test=> cat add.def
DEFINITION MODULE add;

PROCEDURE add(x, y :CARDINAL) :CARDINAL;

END add.
decus: 1751 test=> cat add.mod
IMPLEMENTATION MODULE add;

PROCEDURE add(x, y :CARDINAL) :CARDINAL;
VAR
    z : CARDINAL;
BEGIN
    z := x + y;
    RETURN z
END add;

BEGIN
END add.
decus: 1752 test=> cat addtest.mod
MODULE addtest;

FROM InOut IMPORT WriteLn, WriteString;
FROM NumberIO IMPORT WriteCard;

FROM add IMPORT add;

VAR
    x, y, z :CARDINAL;

BEGIN
    x := 2;
    WriteString("x = "); WriteCard(x, 2); WriteLn;
    y := 3;
    z := add(x, y);
    WriteString("z = "); WriteCard(z, 2); WriteLn;
END addtest.
decus: 1753 test=> gm2 -c add.mod addtest.mod
decus: 1754 test=> file add.o addtest.o
add.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
addtest.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
decus: 1755 test=> gm2 -o addtest addtest.mod add.mod
decus: 1756 test=> file addtest
addtest: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped
decus: 1758 test=> gm2 -o addtest add.mod addtest.mod
decus: 1759 test=> file addtest
addtest: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped
decus: 1760 test=> ./addtest
x =  2
z =  5

Output only occurs if the main module is given last. In fact, gdb-6.8 cannot even
find the init part of the main module unless it is given last.

john




reply via email to

[Prev in Thread] Current Thread [Next in Thread]