Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Yes I have a Machintosh, please don't scream at me. -- Larry Blumette on linux-kernel


devel / comp.os.msdos.djgpp / Re: Linking DXE3 with libraries

SubjectAuthor
* Linking DXE3 with librariesAndris Pavenis (andris.pavenis@iki.fi) [via djgpp@delorie.com]
+* Re: Linking DXE3 with librariesFrank Sapone (emoaddict15@gmail.com) [via djgpp@delorie.com]
|`- Re: Linking DXE3 with librariesAndris Pavenis (andris.pavenis@iki.fi) [via djgpp@delorie.com]
`* Re: Linking DXE3 with librariesOzkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]
 `- Re: Linking DXE3 with librariesOzkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]

1
Linking DXE3 with libraries

<496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>

 copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=275&group=comp.os.msdos.djgpp#275

 copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 28 Jan 2023 11:02:11 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
Received-SPF: neutral (johanna4.inet.fi: domain iki.fi is neutral about
designating 84.248.104.250 as permitted sender) identity=mailfrom;
receiver=johanna4.inet.fi; client-ip=84.248.104.250;
envelope-from=andris.pavenis@iki.fi; helo=[192.168.1.10];
Message-ID: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>
Date: Sat, 28 Jan 2023 12:58:52 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Content-Language: en-US-large
To: "DJGPP List (E-mail)" <djgpp@delorie.com>
From: djgpp@delorie.com (Andris Pavenis (andris.pavenis@iki.fi) [via djgpp@delorie.com])
Subject: Linking DXE3 with libraries
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 43
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-cYml3ODAT+6lFxvBqTTcPo7qFkDkWXkdkdqerQglFrTB/6ElhemMdwaCQmM+LdvR62zlU70RucnDjiZ!QE4hlZtWPJTtBY6wdnTUSJqPpL2hjKN1if5HoAPeh7LkB8WZIdcGvHz36o0CH8P7zi9iVFWL
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Andris Pavenis (andr - Sat, 28 Jan 2023 10:58 UTC

Thread GXE3 with std::vector has grown bit too long, so I'm beginning a new one

I have not used DXE myself, so my thoughts could be inaccurate

Some general thoughts:

- DXE loader has no way to found symbols of running executable (which requests to load DXE) unless
one tells where they are located

- linking DXE directly with libraries (like libstdcxx.a or libc.a) will cause duplicate copy of
symbols. That is going to cause problems when library have global state. I have seen similar
problems, which have often caused crash of program) for example in Linux, when direct of indirect
dependencies causes 2 different versions of shared library to be loaded:

- there is a wat how to provide symbols of executable (including ones from libraries) when loading DXE:

     - http://www.delorie.com/djgpp/v2faq/faq22_15.html

     - https://www.delorie.com/djgpp/doc/utils/utils_20.html

I tried to run DXE3RES under x86_64 Linux, but is seems that DXE3RES is broken when compiled for
64-bit systems:

[andris@ap ~]$ i686-pc-msdosdjgpp-dxe3res -o tmp.c /usr/i686-pc-msdosdjgpp/lib/libc.a
/usr/i686-pc-msdosdjgpp/lib/libc.a: Exec format error

Questions which should be answered to use DXE3 (I do not have answers myself, but can be easily
tested, I'm not going to test myself):

- are constructors and destructors of global objects executed, when these objects belong to DXE? It
seems from source code, that they could. It is perhaps safer to verify that it actually works

I think one should avoid linking DXE with library directly, but provide symbol list generated by
DXE3RES (or manually) instead. Exception could be if DXE module is only user of library, but
program itself does not use it

Andris

Re: Linking DXE3 with libraries

<bb48230b-8090-b8d9-a108-8c90820b40e3@gmail.com>

 copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=277&group=comp.os.msdos.djgpp#277

 copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 28 Jan 2023 11:32:10 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id:from
:to:cc:subject:date:message-id:reply-to;
bh=v3m/7FL5F+JM8itpQXe+nUIi2VCLb8ih7GyCgqxfRRQ=;
b=eA0rMExZrhqEo6v/HOe1uaq6hrfsi7FW06e5xCcNnGp6dpNfWVQcYNka86h8fsgLG1
7BTfwLx0DAzmrZ0xskXnTmuMUiY6L+FabkdjRi00Zh/zXxkMYIVX6a/X1CIj0NEcFwCE
Lf6BWm5Q3ZtzOoGQ+YvrLphj8UaxEsvHnWbj7GapkV1rPR++KerYE4azMhT97WEhCcbr
9GAT1YB96/e3KzmAfIzZEXLduoLMUr1zlIExU2U3UtdWrG+rXY5J9Ob7lAK4JyLpX6kc
PMqiDVD9CJDaM7HH2C7Mm73KRRTRvHu3U9WaIS3rv1dII+ZSJRCqhR0+Vejdfb3IaTCl
b2LQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=v3m/7FL5F+JM8itpQXe+nUIi2VCLb8ih7GyCgqxfRRQ=;
b=KyYy7KGARpUOwe0Mls60gGvNQ3Q+kx0PgcBf9a1AHk4HMrj2WVsqUg41EZiS06k20f
fp35o0fOClyaABiKdl6kqQET/o/RfaopDJaNxRicQ7STj5IIeV2cShMPNgc47fwU56cg
Y9t3EmN2xEhHgFCgRXBR2KJYyO9pH+WOpopCDCFGjDoSL6bI2GzV9eqwsqhErlQrk820
1nfairrNmhUDQ0Hx7bE/8w1RJMdB0y5k0q1s2942p/J4qNzYNayqJgl6Itfnfimlxts3
48FoFXwAwEY9kRoWZAL/9BFGKBo7hvZbzgkgjgnCsP7CulySYintH00KipEXDOGXEi64
V1FA==
X-Gm-Message-State: AO0yUKU9BLYgRgAdUk/1Krayq9AKFD8SNhZ5uAzWDsLEISHWK8929M1m
pjUSgZ101DiSVl/ab8XdlzznnB170bI=
X-Google-Smtp-Source: AK7set/u75AmriUp0i4ZgLeRiFL/vJxudhax/GMCC2UYX05w3OcaGGYPCKXEpaP4+bxdPwea5VbNkg==
X-Received: by 2002:a05:6214:1044:b0:537:7648:aa57 with SMTP id l4-20020a056214104400b005377648aa57mr2065143qvr.52.1674905339336;
Sat, 28 Jan 2023 03:28:59 -0800 (PST)
Message-ID: <bb48230b-8090-b8d9-a108-8c90820b40e3@gmail.com>
Date: Sat, 28 Jan 2023 06:28:57 -0500
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Subject: Re: Linking DXE3 with libraries
To: djgpp@delorie.com
References: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>
Content-Language: en-US
From: djgpp@delorie.com (Frank Sapone (emoaddict15@gmail.com) [via djgpp@delorie.com])
In-Reply-To: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 45
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-vFCc2dlUFPxuClGDquZ/BKIybtp8jXc5Mqc/hxB4iL7FMtgv8kFGmtHNabkSSX5/RpThCEvQtTxRQtM!dF9UQo61bHR2NGlwxtO09OXs36W5LkMI00LgtjRKFjdSdfzZgLid9/LNgxyGS5b6YfkaTTlP87uN
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Frank Sapone (emoadd - Sat, 28 Jan 2023 11:28 UTC

Good Morning Andris,

> - DXE loader has no way to found symbols of running executable (which
> requests to load DXE) unless one tells where they are located
>
Correct, you need a DXE_EXPORT_TABLE with DXE_EXPORT(func/var) to
resolve at run time.  See
https://bitbucket.org/neozeed/q2dos/src/master/dos/dxe.c for an example
if interested.
> - linking DXE directly with libraries (like libstdcxx.a or libc.a)
> will cause duplicate copy of symbols. That is going to cause problems
> when library have global state. I have seen similar problems, which
> have often caused crash of program) for example in Linux, when direct
> of indirect dependencies causes 2 different versions of shared library
> to be loaded:
I'm not quite sure how it works exactly, but with C we just resolve
everything like above, which seems to be the correct way.  With C++
things are trickier and we have to do -lstdcxx -lgcc or we get mangled
names that can't even be exported.
> - are constructors and destructors of global objects executed, when
> these objects belong to DXE? It seems from source code, that they
> could. It is perhaps safer to verify that it actually works
>
I believe so, yes.
>
> I think one should avoid linking DXE with library directly, but
> provide symbol list generated by DXE3RES (or manually) instead.
> Exception could be if DXE module is only user of library, but program
> itself does not use it
>
>
OK, but how do we deal with with the above C++ problem?

I will say that considering it is DOS the likliehood of someone swapping
DXEs around is pretty slim, but I understand why you want to make it
right.  I'd love to contribute code or even something insightful to
these problems but I am not a compiler/compiler tools programmer.  I
also apologize in advance for any dumb or obvious questions I may ask as
a result of this conversation.  I just DXE3GEN like I have been for
years and use the DXE_EXPORT... stuff to resolve at runtime.  This works
quite well for C programs, but C++ requires additional work and it's not
obvious what to do.

Frank

Re: Linking DXE3 with libraries

<CAA2C=vA6APeRO_ccMsucbYpHqy0AfnvEeUAzh87S99MfiqMrSg@mail.gmail.com>

 copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=279&group=comp.os.msdos.djgpp#279

 copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.26.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 28 Jan 2023 11:39:29 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=7AvxyzLAmxyiq6maaqeRyUak5AhA51HbzLNvwzvHQgI=; b=WSNeXtUiJFGmc/1W+7+JQlbbBxlTO069qS/LmtvHFOJCiMSVprSBMlg6yJNKDvh7/8 2HZ3snz8b3IpmjDJIvhJ4Tf+1TXj3dZVKnRmsslCjLroaRA/t8rzz1WB64ZO2ay0V8Lh IAsvpgKoxGNrziMMSlVBXdfMmXU0p+3S+lmMe+N0gWvHhhUuQcyL3Uiamj8qTFO8oHwQ u5wuoB1KjwPddE09m2OzzFJI1IoFBk790YspKLvIYDkb2jKBcb4nFgggCBmoTqT0FIQO cFDcXIrSGPHE6iLIu5GmHLiuWWVqN4V4likXTUO3JeVEpJ6Mg9U6mu05p16jb2v97uFh 2Fqw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7AvxyzLAmxyiq6maaqeRyUak5AhA51HbzLNvwzvHQgI=; b=u4TrniKOer8dsNUhxsFL5JhdeKi1SoVEFnyWFmHeFFou3yGjDeNZZQtpndhChdmzx4 yr1x1H444KgKmiiSO8KwNyprfFB67CVKg0o7Hmjq72wjACdme2Xe/8+cuNwKNQaS0EQm zJRQcO20BSplhVEycJ+StBe76se064Tc0uGCCuwPGS1EHZc2dnHdL1m9wo+N4QvyKxBG p850aW10ldjBbUdn6o7S3E+q22jzCwNLlWXs9BqOTTMtNbkcxtwJHheAVQOAvvxh8ZjX fQBqPGyAOmYK8S2r1w/taT3QYYm9/GC4RkDiS3rMVbi1gipKowG6mTb4NN1ZlmbyfrXk LZAg==
X-Gm-Message-State: AO0yUKWI2DuJXk7umXkDyz+lHwUFGYA/e4gIlZAS9NvQ8yRK1NiGSh0M M/VLLSp/jqMQP3gzugHdHIdKRoYXj9rHQTIEzEQ9IJD1
X-Google-Smtp-Source: AK7set9h7RUrfM1fDkiC8hXLFQzD0/NeovjTeuBGs1KL4UYyUKx5DUpN14q4+S+UPLzDVHC+5hvwgPSeClvlPDBnF3o=
X-Received: by 2002:a05:6000:170e:b0:2bf:b77b:fafc with SMTP id n14-20020a056000170e00b002bfb77bfafcmr567540wrc.475.1674905778986; Sat, 28 Jan 2023 03:36:18 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>
References: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi>
From: djgpp@delorie.com (Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com])
Date: Sat, 28 Jan 2023 14:36:18 +0300
Message-ID: <CAA2C=vA6APeRO_ccMsucbYpHqy0AfnvEeUAzh87S99MfiqMrSg@mail.gmail.com>
Subject: Re: Linking DXE3 with libraries
To: djgpp@delorie.com
Content-Type: text/plain; charset="UTF-8"
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 35
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-u5EHyVjHwouxnG7nl2D6gDTq1guDRV93O/jyXxbor7siSEoq/6zR9lPcNdpyD7RC2zuS1l/FHvTI23Q!ybci8+BUNIVso3cA4drzgklfwgWv0xyJGRMeIBILqboZFSIL6f7Tt+DWm0LiLrfDZWk5zZK6AdlX!YrINesj0JG7169+8p7S4ly0GjXc=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ozkan Sezer (sezeroz - Sat, 28 Jan 2023 11:36 UTC

On 1/28/23, Andris Pavenis (andris.pavenis@iki.fi) [via
djgpp@delorie.com] <djgpp@delorie.com> wrote:
> I have not used DXE myself, so my thoughts could be inaccurate
>
> Some general thoughts:
>
> - DXE loader has no way to found symbols of running executable (which
> requests to load DXE) unless
> one tells where they are located

General issue

> - linking DXE directly with libraries (like libstdcxx.a or libc.a) will
> cause duplicate copy of symbols.

Linking with libc.a can be especially problematic.

However, if you have a dxe written in c++, and especially if your
exe is C-only, linking dxe with libstdc++ is a good thing

As for duplication of symbols: Well that's a known general issue
because djgpp libc is a static library.

> I tried to run DXE3RES under x86_64 Linux, but is seems that DXE3RES is
> broken when compiled for
> 64-bit systems:
>
> [andris@ap ~]$ i686-pc-msdosdjgpp-dxe3res -o tmp.c
> /usr/i686-pc-msdosdjgpp/lib/libc.a
> /usr/i686-pc-msdosdjgpp/lib/libc.a: Exec format error

You should run dxe3res against a dxe module, not an archive,
like: dxe3gen -o tmp.c my.dxe

As for rest of your notes, I will try looking at them later.

Re: Linking DXE3 with libraries

<CAA2C=vDbGtYcjO0MTK4tys3YejP8kbMK86JZ7tpmZqpqEm00bw@mail.gmail.com>

 copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=281&group=comp.os.msdos.djgpp#281

 copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 28 Jan 2023 12:04:49 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:references:in-reply-to:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=7JE8Dk68L9eu+V0wMSgFkks161RBRyFjZx+tGX/aazM=;
b=DEUMz1g6IjQnbt3vQFUZWLB7x6McUtSb4bHpdETi7aZ3XHWLGHaHu/6ZaroM2iwOm+
9J1G1iajENgq2wscrrQ7/FfDZs8KeTKy08hwEE7gtfLBZWX/PvYxa4naA6Qfq8PkljOv
tR2R6xSpb5/VXZ3i2CfaBL6kZ6gYNFqw5f9/cNeId6yj+4KpC31CWXCXPj1O9osKaX/o
oFk2wP4rF9W0nK6ZrAQJOI6qC1fKxMH7SXiKNKMAv4K9+fI5UhGa+j/t43T7XEJmjqPE
3/A54IczBcEOi6DBNbJIler972u/JBWKALlwq8BE7zFUNH0ZXp9L+jv7u76FaD5nnsiK
87yg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:references:in-reply-to:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=7JE8Dk68L9eu+V0wMSgFkks161RBRyFjZx+tGX/aazM=;
b=2GQB9wHexBmGpuhCqz2m8zIbQXVBZfTh1ACC0ICJHc4Ly1Tb5EOEZx22Dag+ZE88nH
PtXW3tlzWG+og26h9Bdr71b5QFaTv7l6qK2FuNWb+8wolAyXKmATFn/MNzsSh60aHPx8
6tBfLjcZyCNZCngzCzfJsbp5gT5J9tcxkTFqj75LMOvYE9mOBgNnjAkY/uOWz536mbLR
oM6F26cHrHUQd6+nVhxGDsgA7OQ0LkNKQDU7EI45tMqMEhFdM8FB5LNer5M19Z+p9aYj
Il2rf9DAXsjBWHVyLUDgfX02QGtmDrjbeARyMHP4nNnvwLbYoWWs8Pfv6tJ6hJdU3wEJ
2cVw==
X-Gm-Message-State: AFqh2kozgK24xv5Lw6Z7+i7QW6KqDYQ/zGzpRMp4Sxy4YTkub9bIt0ku
L4UV/t1M0+136lIW1warYhp5VUCpw5fbB72w0ngn7su3
X-Google-Smtp-Source: AMrXdXu9GBbTdhw2UWN8yHOrSsAm/u7qLIYWpW/dL0lTJsbrLFLyLKSmpg36NK8QPSHAKzbel4N1GNthayOfc4q+B8E=
X-Received: by 2002:a1c:e915:0:b0:3d9:722c:b60c with SMTP id
q21-20020a1ce915000000b003d9722cb60cmr2512994wmc.181.1674907300503; Sat, 28
Jan 2023 04:01:40 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <CAA2C=vA6APeRO_ccMsucbYpHqy0AfnvEeUAzh87S99MfiqMrSg@mail.gmail.com>
References: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi> <CAA2C=vA6APeRO_ccMsucbYpHqy0AfnvEeUAzh87S99MfiqMrSg@mail.gmail.com>
From: djgpp@delorie.com (Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com])
Date: Sat, 28 Jan 2023 15:01:39 +0300
Message-ID: <CAA2C=vDbGtYcjO0MTK4tys3YejP8kbMK86JZ7tpmZqpqEm00bw@mail.gmail.com>
Subject: Re: Linking DXE3 with libraries
To: djgpp@delorie.com
Content-Type: text/plain; charset="UTF-8"
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 13
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-shAeVW/mvLqqiEGGe/UW5LiGB5dOYyWsCzEfQvn8xbfO5jme0jGdzRze/JEZX/clFT4Z8IBInfBGlAy!SuejLvq5adV3ronUkmEIEdYwt/yce1c0nLrIOT+yLK6J+NRwzyt8XfVxxFQkpKRggsVlsXa84Ta0!F9PczKywjTNKWsB3PJriZhogu4U=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ozkan Sezer (sezeroz - Sat, 28 Jan 2023 12:01 UTC

>> I tried to run DXE3RES under x86_64 Linux, but is seems that DXE3RES is
>> broken when compiled for
>> 64-bit systems:
>>
>> [andris@ap ~]$ i686-pc-msdosdjgpp-dxe3res -o tmp.c
>> /usr/i686-pc-msdosdjgpp/lib/libc.a
>> /usr/i686-pc-msdosdjgpp/lib/libc.a: Exec format error
>
> You should run dxe3res against a dxe module, not an archive,
> like: dxe3gen -o tmp.c my.dxe

Fixing my silly typo:
dxe3res -o tmp.c my.dxe

Re: Linking DXE3 with libraries

<54690cf9-1ba6-acda-de67-c08071fbb5d7@iki.fi>

 copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=289&group=comp.os.msdos.djgpp#289

 copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.22.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 28 Jan 2023 16:20:20 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
Received-SPF: neutral (johanna4.inet.fi: domain iki.fi is neutral about designating 84.248.104.250 as permitted sender) identity=mailfrom; receiver=johanna4.inet.fi; client-ip=84.248.104.250; envelope-from=andris.pavenis@iki.fi; helo=[192.168.1.10];
Message-ID: <54690cf9-1ba6-acda-de67-c08071fbb5d7@iki.fi>
Date: Sat, 28 Jan 2023 18:17:02 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1
Subject: Re: Linking DXE3 with libraries
Content-Language: en-US-large
To: djgpp@delorie.com
References: <496da509-6d4f-88a1-e94a-6c330a915f05@iki.fi> <bb48230b-8090-b8d9-a108-8c90820b40e3@gmail.com>
From: djgpp@delorie.com (Andris Pavenis (andris.pavenis@iki.fi) [via djgpp@delorie.com])
In-Reply-To: <bb48230b-8090-b8d9-a108-8c90820b40e3@gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 118
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-X1oRhSppYpWmSi2s5DHoZLY+QuU55NvPj6bDmpzRHwX8Fr6BlEHhwYdso0THGt/j9O1UcpxxoSRAtYH!7J/BTYlcnt0VqCi5gmaz6rxi4iAveLVVF6t8NUa6suuAiawJiyA8JsvM8S93vsfPatzwrfxr
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 8116
 by: Andris Pavenis (andr - Sat, 28 Jan 2023 16:17 UTC

On 1/28/23 13:28, Frank Sapone (emoaddict15@gmail.com) [via djgpp@delorie.com] wrote:
> Good Morning Andris,
>
>> - DXE loader has no way to found symbols of running executable (which requests to load DXE)
>> unless one tells where they are located
>>
> Correct, you need a DXE_EXPORT_TABLE with DXE_EXPORT(func/var) to resolve at run time.  See
> https://bitbucket.org/neozeed/q2dos/src/master/dos/dxe.c for an example if interested.
>> - linking DXE directly with libraries (like libstdcxx.a or libc.a) will cause duplicate copy of
>> symbols. That is going to cause problems when library have global state. I have seen similar
>> problems, which have often caused crash of program) for example in Linux, when direct of
>> indirect dependencies causes 2 different versions of shared library to be loaded:
> I'm not quite sure how it works exactly, but with C we just resolve everything like above, which
> seems to be the correct way. With C++ things are trickier and we have to do -lstdcxx -lgcc or we
> get mangled names that can't even be exported.

The following could work (I only tried under Linux, so for native DJGPP and/or other libraries one
should modify script):

[andris@ap dxe]$ cat mk_lib_export_table.sh
#! /bin/sh

i686-pc-msdosdjgpp-nm --extern-only /usr/i686-pc-msdosdjgpp/lib/libstdc++.a |\
awk '/^[0-9A-H]/ && ($2 == "W" || $2 == "T") { print $3 }' | sort | uniq |\
sed -e 's/^_//' >symbols.tmp

(
   echo "#include <sys/dxe.h>"
   echo ""
   awk '{ print "extern void ", $1, "();"}' symbols.tmp
   echo ""
   echo "DXE_EXPORT_TABLE (exported_symbols)"
   awk '{print "  DXE_EXPORT(",$1,")"}' symbols.tmp
   echo "DXE_EXPORT_END"
   echo ""
   echo "int main() { return 0; }"
) | i686-pc-msdosdjgpp-gcc -v -O0 -fno-builtin -x c - -l stdc++

Only added main() to avoid having linker error.

Also linked executable to verify that symbols are extracted correctly.

One can there put code to register generated export table instead.

I only tried gcc-12.2.0.

Output of script is given below

Andris

[andris@ap dxe]$ ./mk_lib_export_table.sh
Using built-in specs.
COLLECT_GCC=i686-pc-msdosdjgpp-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/lto-wrapper
Kohde: i686-pc-msdosdjgpp
Configured with: ../gcc-12.2.0/configure --prefix=/usr --libexecdir=/usr/lib
--target=i686-pc-msdosdjgpp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-shared
--enable-static --enable-th
reads=no --with-system-zlib --with-isl --enable-lto --disable-libgomp --disable-multilib
--enable-checking=release --disable-libstdcxx-pch --enable-libstdcxx-filesystem-ts
--disable-install-libi
berty
Säiemalli: single
Supported LTO compression algorithms: zlib zstd
gcc-versio 12.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-O0' '-fno-builtin' '-mtune=generic' '-march=pentiumpro' '-dumpdir' 'a-'
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/cc1 -quiet -v -remap - -quiet -dumpdir a- -dumpbase -
-mtune=generic -march=pentiumpro -O0 -version -fno-builtin -o /tmp/cchC3Spt.s
GNU C17 (GCC) versio 12.2.0 (i686-pc-msdosdjgpp)
       käännetty GNU C:n versiolla 12.1.1 20220730, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC
version 1.2.1, isl version isl-0.25-GMP

warning: MPFR-otsakeversio 4.1.0-p13 eroaa kirjastoversiosta 4.1.1-p1.
warning: MPC-otsakeversio 1.2.1 eroaa kirjastoversiosta 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
jätetään puuttuva hakemisto ”/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/include-fixed” huomiotta
#include "..." -haku alkaa täältä:
#include <...> -haku alkaa täältä:
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/include
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/sys-include
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/include
Hakulistan loppu.
GNU C17 (GCC) versio 12.2.0 (i686-pc-msdosdjgpp)
       käännetty GNU C:n versiolla 12.1.1 20220730, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC
version 1.2.1, isl version isl-0.25-GMP

warning: MPFR-otsakeversio 4.1.0-p13 eroaa kirjastoversiosta 4.1.1-p1.
warning: MPC-otsakeversio 1.2.1 eroaa kirjastoversiosta 1.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 80ce3899c685b09c12b70d8ca8f6fbac
COLLECT_GCC_OPTIONS='-v' '-O0' '-fno-builtin' '-mtune=generic' '-march=pentiumpro' '-dumpdir' 'a-'
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/bin/as -v -o /tmp/ccIgzJio.o
/tmp/cchC3Spt.s
GNU assembler version 2.34 (i686-pc-msdosdjgpp) using BFD version (GNU Binutils) 2.34
COMPILER_PATH=/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/:/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/:/usr/lib/gcc/i686-pc-msdosdjgpp/:/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/:/usr/lib/gcc/i686-pc-msdosd
jgpp/:/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/:/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/lib/

COLLECT_GCC_OPTIONS='-v' '-O0' '-fno-builtin' '-mtune=generic' '-march=pentiumpro' '-dumpdir' 'a.'
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/collect2 -plugin
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/lto-wrapper -plugin-opt=-freso
lution=/tmp/cc8Rf9cH.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/lib/c
rt0.o -L/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0
-L/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/lib /tmp/ccIgzJio.o
-lstdc++ -lgcc -lc -lgcc
COLLECT_GCC_OPTIONS='-v' '-O0' '-fno-builtin' '-mtune=generic' '-march=pentiumpro' '-dumpdir' 'a.'
/usr/lib/gcc/i686-pc-msdosdjgpp/12.2.0/../../../../i686-pc-msdosdjgpp/bin/stubify -v a.out
stubify for djgpp V2.X executables, Copyright (C) 1995-2003 DJ Delorie
stubify: a.out -> a.000 -> a.exe

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor