From owner-freebsd-hackers Tue Feb 25 10:04:36 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA06006 for hackers-outgoing; Tue, 25 Feb 1997 10:04:36 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id KAA05998 for ; Tue, 25 Feb 1997 10:04:32 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id LAA26691; Tue, 25 Feb 1997 11:01:23 -0700 From: Terry Lambert Message-Id: <199702251801.LAA26691@phaeton.artisoft.com> Subject: Re: Static variables in shared libraries To: bakul@torrentnet.com (Bakul Shah) Date: Tue, 25 Feb 1997 11:01:23 -0700 (MST) Cc: peterh@prognet.com, freebsd-hackers@FreeBSD.ORG In-Reply-To: <199702251650.LAA01376@chai.plexuscom.com> from "Bakul Shah" at Feb 25, 97 11:50:21 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > I have a shared library which has the following definitions: > > > > const char* test_3 = "hello"; > > const char* test_4 = test_3; > > > > If I dynamically load this shared library in my program and print the > > variables, I get: > > test_3 = "hello" > > test_4 = 0x0 > > > > What's going on? > > May be shlib linking is broken? Looks more like an agregate initialization problem with consts not being treated as fixed addresses by the compiler the way strings are... in other words, a compiler or linker bug resolving the test_4 address to the address of the agregate initialized data containing the string "hello", and the same address as it resolved test_3 to. On wonder why you want to establish a const alias, actually. The const definition implies noalias. 8-|. Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.