From owner-freebsd-commit Mon Jan 15 09:53:53 1996 Return-Path: owner-commit Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA27231 for freebsd-commit-outgoing; Mon, 15 Jan 1996 09:53:53 -0800 (PST) Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA27215 for cvs-all-outgoing; Mon, 15 Jan 1996 09:53:32 -0800 (PST) Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA27205 for cvs-lib-outgoing; Mon, 15 Jan 1996 09:53:29 -0800 (PST) Received: (from jdp@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA27198 Mon, 15 Jan 1996 09:53:27 -0800 (PST) Date: Mon, 15 Jan 1996 09:53:27 -0800 (PST) From: John Polstra Message-Id: <199601151753.JAA27198@freefall.freebsd.org> To: CVS-committers, cvs-lib Subject: cvs commit: src/lib/csu/i386 c++rt0.c Sender: owner-commit@FreeBSD.ORG Precedence: bulk jdp 96/01/15 09:53:27 Modified: lib/csu/i386 c++rt0.c Log: Check the count in the first word of __CTOR_LIST__ before executing the loop that invokes the static constructors. That makes it safe to link c++rt0.o into any shared library, even one that does not have any static constructors. Formerly, doing that would cause a bus error. If the library has no static constructors, __CTOR_LIST__ comes out as a simple 4-byte COMMON region, and it does not have the usual NULL word that terminates the list of constructors. This caused the old code to "call" a garbage address via the non-existent entry __CTOR_LIST__[1]. The analogous code that invokes the static destructors was already safe. This change is fully backward-compatible. Reviewed by: dfr@render.com (Doug Rabson) Revision Changes Path 1.4 +12 -4 src/lib/csu/i386/c++rt0.c