Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jan 2000 06:00:03 +0100 (MET)
From:      Jean-Marc Zucconi <jmz@FreeBSD.org>
To:        louie@TransSys.COM
Cc:        current@FreeBSD.org
Subject:   Re: new C++ compiler changes
Message-ID:  <200001300500.GAA10115@qix.jmz.org>
In-Reply-To: <200001290007.TAA05379@whizzo.transsys.com> (louie@TransSys.COM)
References:   <200001290007.TAA05379@whizzo.transsys.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> Louis A Mamakos writes:

 > I just put a new -current on my test machine, and watched a bunch of stuff
 > fall over and die due to the new C++ implementation.

 > Is it possible to bump the revision of libstdc++ (and perhaps others) so
 > that existing programs can continue to function?  I fear I will be
 > tracking down occasional broken C++ programs for days now.

The solution I adopted is to keep the old libstdc++.so.3 and rename it
libstdc++.so.1. Then you just have to modify your executable so that
it looks for libstdc++.so.1 instead of libstdc++.so.3 (script below
:-))

Jean-Marc

#!/usr/bin/perl

if (!$ARGV[0] || $ARGV[0] eq "-h") {
    print STDERR "usage: $0 file...\n";
    exit 1;
}
foreach (@ARGV) {
    if (! -f $_) {
	print STDERR "$_: not found\n";
    } else {
	($s) = `file $_`;
	if ($s !~ /: ELF.*dynamically linked/) {
	    print STDERR "$_: bad format\n$s";
	} else {
	    @h = `objdump -h $_`;
	    $done = 0;
	    foreach $s (@h) {
		if ($s =~ /dynstr/) {
		    &edit ($_, $s);
		    $done = 1;
		}
	    }
	    if (!$done) {
		print STDERR "$_: no .dynstr section\n";
	    }
	}
    }
}
sub edit {
    $f = shift;
    $_ = shift;
    split;
    $len = hex ($_[2]);
    $skip = hex ($_[5]);
    if (!open (F, $f)) {
	print STDERR "$f: $!\n";
	return;
    }
    $n = sysread (F, $a, $skip);
    if ($n != $skip) {
	print STDERR "$f: short read\n";
	return;
    }
    $n = sysread (F, $_, $len);
    if ($n != $len) {
	print STDERR "$f: short read\n";
	return;
    }
    if (! /libstdc\+\+.so.3/) {
	print STDERR "$f: libstdc++.so.3 not used\n";
	return;
    }
    s/libstdc\+\+.so.3/libstdc++.so.1/;
    if (!open (G, ">$f.1")) {
	print STDERR "can't create $f.1\n";
	close F;
	return;
    }
    syswrite (G, $a, $skip);
    syswrite (G, $_, $len);
    while ($n != 0) {
	$n = sysread (F, $_, 100000);
	if ($n < 0) {
	    print STDERR "$f: read error\n";
	    close F;
	    close G;
	    return;
	}
	if ($n != 0) {
	    $w = syswrite (G, $_, $n);
	    if ($n < $w) {
		print STDERR "$f.1: write error\n";
		close F;
		close G;
		return;
	    }
	}
    }
    close F;
    close G;
    system ("mv $f $f.backup && mv $f.1 $f");
}

-- 
 Jean-Marc Zucconi                    PGP Key: finger jmz@FreeBSD.ORG


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001300500.GAA10115>