summaryrefslogtreecommitdiff
path: root/usr.bin/libtool/LT
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/libtool/LT')
-rw-r--r--usr.bin/libtool/LT/Archive.pm5
-rw-r--r--usr.bin/libtool/LT/Mode/Link.pm38
-rw-r--r--usr.bin/libtool/LT/Mode/Link/Program.pm8
-rw-r--r--usr.bin/libtool/LT/UList.pm10
4 files changed, 32 insertions, 29 deletions
diff --git a/usr.bin/libtool/LT/Archive.pm b/usr.bin/libtool/LT/Archive.pm
index 4fa088f7164..736a29c4853 100644
--- a/usr.bin/libtool/LT/Archive.pm
+++ b/usr.bin/libtool/LT/Archive.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Archive.pm,v 1.6 2014/04/16 10:31:27 zhuk Exp $
+# $OpenBSD: Archive.pm,v 1.7 2014/04/20 17:34:26 zhuk Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -58,8 +58,7 @@ sub get_symbollist
tsay {"generating symbol list in file: $filepath"};
tsay {"object list is @$objlist" };
- my $symbols = [];
- tie (@$symbols, 'LT::UList');
+ my $symbols = LT::UList->new;
open(my $sh, '-|', 'nm', '--', @$objlist) or
die "Error running nm on object list @$objlist\n";
my $c = 0;
diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm
index 37809dad057..6f38e5fd978 100644
--- a/usr.bin/libtool/LT/Mode/Link.pm
+++ b/usr.bin/libtool/LT/Mode/Link.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Link.pm,v 1.27 2014/04/16 14:39:06 zhuk Exp $
+# $OpenBSD: Link.pm,v 1.28 2014/04/20 17:34:26 zhuk Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -23,18 +23,19 @@ use feature qw(say);
package LT::OSConfig;
require LT::UList;
-my $search_dir_obj = tie(my @search_dir_list, 'LT::UList');
+my $search_dir_list = LT::UList->new;
+my $search_dir_obj = tied(@$search_dir_list);
sub fillup_search_dirs
{
- return if @search_dir_list;
+ return if @$search_dir_list;
open(my $fh, '-|', '/sbin/ldconfig -r');
if (!defined $fh) {
die "Can't run ldconfig\n";
}
while (<$fh>) {
if (m/^\s*search directories:\s*(.*?)\s*$/o) {
- push @search_dir_list, split(/\:/o, $1);
+ push @$search_dir_list, split(/\:/o, $1);
last;
}
}
@@ -45,7 +46,7 @@ sub search_dirs
{
my $self = shift;
$self->fillup_search_dirs;
- return @search_dir_list;
+ return @$search_dir_list;
}
sub is_search_dir
@@ -117,11 +118,10 @@ sub run
my $noshared = $ltconfig->noshared;
my $cmd;
- my $libdirs = []; # list of libdirs
- tie (@$libdirs, 'LT::UList');
+ my $libdirs = LT::UList->new; # list of libdirs
my $libs = LT::Library::Stash->new; # libraries
- my $dirs = []; # paths to find libraries
- tie (@$dirs, 'LT::UList', '/usr/lib'); # always look here
+ my $dirs = LT::UList->new('/usr/lib'); # paths to search for libraries,
+ # /usr/lib is always there
$gp->handle_permuted_options(
'all-static',
@@ -197,8 +197,7 @@ sub run
tsay {"objs = @objs"};
tsay {"sobjs = @sobjs"};
- my $deplibs = []; # list of dependent libraries (both -L and -l flags)
- tie (@$deplibs, 'LT::UList');
+ my $deplibs = LT::UList->new; # list of dependent libraries (both -L and -l flags)
my $parser = LT::Parser->new(\@ARGV);
if ($linkmode == PROGRAM) {
@@ -224,8 +223,7 @@ sub run
tsay {"hoping for real objects in ARGV..."};
}
}
- tie(my @temp, 'LT::UList', @Ropts, @RPopts, $gp->Rresolved);
- my $RPdirs = \@temp;
+ my $RPdirs = LT::UList->new(@Ropts, @RPopts, $gp->Rresolved);
$program->{RPdirs} = $RPdirs;
$program->link($ltprog, $ltconfig, $dirs, $libs, $deplibs, $libdirs, $parser, $gp);
@@ -447,10 +445,10 @@ sub build_cache
{
my ($self, $lainfo, $level) = @_;
my $o = $lainfo->{cached} = {
- deplibs => [], libdirs => [], result => [] };
- tie @{$o->{deplibs}}, 'LT::UList';
- tie @{$o->{libdirs}}, 'LT::UList';
- tie @{$o->{result}}, 'LT::UList';
+ deplibs => LT::UList->new,
+ libdirs => LT::UList->new,
+ result => LT::UList->new
+ };
$self->internal_resolve_la($o, $lainfo->deplib_list,
$level+1);
push(@{$o->{deplibs}}, @{$lainfo->deplib_list});
@@ -744,8 +742,7 @@ sub create_symlinks
my $f = $l->{fullpath};
next if !defined $f;
next if $f =~ m/\.a$/;
- my $libnames = [];
- tie (@$libnames, 'LT::UList');
+ my $libnames = LT::UList->new;
if (defined $l->{lafile}) {
require LT::LaFile;
my $lainfo = LT::LaFile->parse($l->{lafile});
@@ -773,8 +770,7 @@ sub common1
my ($self, $parser, $gp, $deplibs, $libdirs, $dirs, $libs) = @_;
$parser->resolve_la($deplibs, $libdirs);
- my $orderedlibs = [];
- tie(@$orderedlibs, 'LT::UList');
+ my $orderedlibs = LT::UList->new;
my $staticlibs = [];
my $args = $parser->parse_linkargs2($gp, $orderedlibs, $staticlibs, $dirs,
$libs);
diff --git a/usr.bin/libtool/LT/Mode/Link/Program.pm b/usr.bin/libtool/LT/Mode/Link/Program.pm
index 29d4b551043..3ea2e8e4a0f 100644
--- a/usr.bin/libtool/LT/Mode/Link/Program.pm
+++ b/usr.bin/libtool/LT/Mode/Link/Program.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Program.pm,v 1.5 2014/04/16 14:39:06 zhuk Exp $
+# $OpenBSD: Program.pm,v 1.6 2014/04/20 17:34:26 zhuk Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -68,11 +68,11 @@ sub link
$dst = ($odir eq '.') ? $fname : "$odir/$fname";
}
- tie(my @rpath_link, 'LT::UList');
+ my $rpath_link = LT::UList->new;
# add libdirs to rpath if they are not in standard lib path
for my $l (@$libdirs) {
if (LT::OSConfig->is_search_dir($l)) {
- push @rpath_link, $l;
+ push @$rpath_link, $l;
} else {
push @$RPdirs, $l;
}
@@ -105,7 +105,7 @@ sub link
for my $d (@$RPdirs) {
push(@linkeropts, '-rpath', $d);
}
- for my $d (@rpath_link) {
+ for my $d (@$rpath_link) {
push(@linkeropts, '-rpath-link', $d);
}
}
diff --git a/usr.bin/libtool/LT/UList.pm b/usr.bin/libtool/LT/UList.pm
index 99186f10759..08ecf506fa7 100644
--- a/usr.bin/libtool/LT/UList.pm
+++ b/usr.bin/libtool/LT/UList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UList.pm,v 1.1 2014/04/16 10:31:27 zhuk Exp $
+# $OpenBSD: UList.pm,v 1.2 2014/04/20 17:34:26 zhuk Exp $
#
# Copyright (c) 2013 Vadim Zhukov <zhuk@openbsd.org>
#
@@ -38,6 +38,14 @@ sub _translate_num_key($$;$) {
die "invalid index" if $_[1] - int($_[2] // 0) >= @{$_[0]};
}
+# Construct new UList and returnes reference to the array,
+# not to the tied object itself.
+sub new {
+ my $class = shift;
+ tie(my @a, $class, @_);
+ return \@a;
+}
+
# Given we have successfully added N directories:
# self->[0] = { directory => 1 }
# self->[1 .. N] = directories in the order of addition, represented as 0..N-1