summaryrefslogtreecommitdiff
path: root/usr/src/cmd/sgs/libldstab
diff options
context:
space:
mode:
authorAli Bahrami <Ali.Bahrami@Sun.COM>2008-12-09 10:54:10 -0700
committerAli Bahrami <Ali.Bahrami@Sun.COM>2008-12-09 10:54:10 -0700
commitd2d5cf7c5d909b74a88d499283e24750a9a52c5d (patch)
tree84056ff7753630dde28e663a51fd53257a99a948 /usr/src/cmd/sgs/libldstab
parent3534c68111163b60e274fa816769616d177a08b7 (diff)
downloadillumos-joyent-d2d5cf7c5d909b74a88d499283e24750a9a52c5d.tar.gz
6775062 remove /usr/lib/libldstab.so
Diffstat (limited to 'usr/src/cmd/sgs/libldstab')
-rw-r--r--usr/src/cmd/sgs/libldstab/Makefile.com22
-rw-r--r--usr/src/cmd/sgs/libldstab/Makefile.targ14
-rw-r--r--usr/src/cmd/sgs/libldstab/common/libldstab.msg74
-rw-r--r--usr/src/cmd/sgs/libldstab/common/mapfile-6414
-rw-r--r--usr/src/cmd/sgs/libldstab/common/mapfile-vers17
-rw-r--r--usr/src/cmd/sgs/libldstab/common/stab.c643
-rw-r--r--usr/src/cmd/sgs/libldstab/common/stab.h230
7 files changed, 49 insertions, 965 deletions
diff --git a/usr/src/cmd/sgs/libldstab/Makefile.com b/usr/src/cmd/sgs/libldstab/Makefile.com
index 91f93046a1..bd0ad2c294 100644
--- a/usr/src/cmd/sgs/libldstab/Makefile.com
+++ b/usr/src/cmd/sgs/libldstab/Makefile.com
@@ -19,20 +19,17 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
LIBRARY= libldstab.a
VERS= .1
COMOBJS= stab.o
DUPOBJS+=
-BLTOBJ= msg.o
-OBJECTS= $(BLTOBJ) $(COMOBJS) $(DUPOBJS)
+OBJECTS= $(COMOBJS) $(DUPOBJS)
include $(SRC)/lib/Makefile.lib
include $(SRC)/cmd/sgs/Makefile.com
@@ -59,21 +56,10 @@ XXXFLAGS=
$(DYNLIB) := XXXFLAGS= $(USE_PROTO)
DYNFLAGS += $(XXXFLAGS)
-BLTDEFS= msg.h
-BLTDATA= msg.c
-BLTMESG= $(SGSMSGDIR)/libldstab
-
-BLTFILES= $(BLTDEFS) $(BLTDATA) $(BLTMESG)
-
-SGSMSGCOM= ../common/libldstab.msg
-SGSMSGALL= $(SGSMSGCOM)
-SGSMSGTARG= $(SGSMSGCOM)
-SGSMSGFLAGS += -h $(BLTDEFS) -d $(BLTDATA) -m $(BLTMESG) -n libldstab_msg
-
-SRCS= $(COMOBJS:%.o=../common/%.c) $(BLTDATA)
+SRCS= $(COMOBJS:%.o=../common/%.c)
LINTSRCS= $(SRCS)
-CLEANFILES += $(LINTOUTS) $(BLTFILES)
+CLEANFILES += $(LINTOUTS)
CLOBBERFILES += $(DYNLIB)
ROOTDYNLIB= $(DYNLIB:%=$(ROOTLIBDIR)/%)
diff --git a/usr/src/cmd/sgs/libldstab/Makefile.targ b/usr/src/cmd/sgs/libldstab/Makefile.targ
index 9ffef5b4d5..b20710f983 100644
--- a/usr/src/cmd/sgs/libldstab/Makefile.targ
+++ b/usr/src/cmd/sgs/libldstab/Makefile.targ
@@ -19,11 +19,9 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
pics/%.o: ../common/%.c
$(COMPILE.c) -o $@ $<
@@ -53,12 +51,8 @@ include $(SRC)/cmd/sgs/Makefile.targ
# Derived source and header files (messaging).
-catalog: $(BLTMESG)
+catalog:
-chkmsg: $(SRCS)
- sh $(CHKMSG) $(CHKMSGFLAGS) $(SRCS)
+chkmsg:
-$(BLTDEFS) + \
-$(BLTDATA) + \
-$(BLTMESG) : $(SGSMSGALL)
- $(SGSMSG) $(SGSMSGFLAGS) $(SGSMSGALL)
+package:
diff --git a/usr/src/cmd/sgs/libldstab/common/libldstab.msg b/usr/src/cmd/sgs/libldstab/common/libldstab.msg
deleted file mode 100644
index 4fe0361e8d..0000000000
--- a/usr/src/cmd/sgs/libldstab/common/libldstab.msg
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# ident "%Z%%M% %I% %E% SMI"
-
-
-@ _START_
-
-# Message file for cmd/sgs/libldstab.
-
-@ MSG_ID_LIBLDSTAB
-
-
-# Stab processing errors.
-
-@ MSG_STAB_MISTBL "libldstab: file %s: .stab[.index|.sbfocus] found \
- with no matching string table\n"
-@ MSG_STAB_BADTBL "libldstab: file %s: .stab[.index|.sbfocus] error \
- when reading string table\n"
-@ MSG_STAB_NOSBROW "SourceBrowser data will be lost"
-
-# System errors
-
-@ MSG_SYS_EXEC "libldstab: file %s: %s exec failed: %s: %s\n"
-@ MSG_SYS_FORK "libldstab: file %s: fork failed: %s: %s\n"
-@ MSG_SYS_GETCWD "libldstab: file %s: getcwd failed: %s\n"
-
-@ MSG_ELF_GETDATA "libldstab: file %s: elf_getdata: %s\n"
-@ MSG_ELF_GETSCN "libldstab: file %s: elf_getscn: %s\n"
-
-@ _END_
-
-# The following strings represent reserved names. Reference to these strings
-# is via the MSG_ORIG() macro, and thus translations are not required.
-
-# Elf processing messages.
-
-@ MSG_STR_DASHR "-r"
-@ MSG_STR_DASHX "-x"
-@ MSG_STR_W "w"
-
-@ MSG_STR_SBFOCUS "sbfocus"
-
-@ MSG_SUNW_OST_SGS "SUNW_OST_SGS"
-
-# Section strings
-
-@ MSG_SCN_STAB ".stab"
-@ MSG_SCN_STABSTR ".stabstr"
-@ MSG_SCN_STABINDEX ".stab.index"
-@ MSG_SCN_STABINDEXSTR ".stab.indexstr"
-@ MSG_SCN_STABSBFOCUS ".stab.sbfocus"
-@ MSG_SCN_STABSBFOCUSTR ".stab.sbfocusstr"
diff --git a/usr/src/cmd/sgs/libldstab/common/mapfile-64 b/usr/src/cmd/sgs/libldstab/common/mapfile-64
index 8b0dfac4db..47759d6adc 100644
--- a/usr/src/cmd/sgs/libldstab/common/mapfile-64
+++ b/usr/src/cmd/sgs/libldstab/common/mapfile-64
@@ -1,15 +1,12 @@
#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -28,8 +25,5 @@
SUNWprivate_1.1 {
global:
- ld_atexit64;
- ld_file64;
- ld_section64;
- ld_start64;
+ ld_version64;
};
diff --git a/usr/src/cmd/sgs/libldstab/common/mapfile-vers b/usr/src/cmd/sgs/libldstab/common/mapfile-vers
index b1f190c814..10fe1ce804 100644
--- a/usr/src/cmd/sgs/libldstab/common/mapfile-vers
+++ b/usr/src/cmd/sgs/libldstab/common/mapfile-vers
@@ -1,15 +1,12 @@
#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -28,16 +25,10 @@
SUNWprivate_1.1 {
global:
- ld_atexit;
- ld_file;
- ld_section;
- ld_start;
+ ld_version;
};
{
- global:
- eprintf = FUNCTION extern;
- libld_malloc = FUNCTION extern;
local:
*;
};
diff --git a/usr/src/cmd/sgs/libldstab/common/stab.c b/usr/src/cmd/sgs/libldstab/common/stab.c
index 1f8a00a289..92eef3d774 100644
--- a/usr/src/cmd/sgs/libldstab/common/stab.c
+++ b/usr/src/cmd/sgs/libldstab/common/stab.c
@@ -24,627 +24,50 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This file contains all functions relating to stab processing. The
- * stab table is compressed by eliminating duplicate include file entries.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stab.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <errno.h>
-#include <libintl.h>
-#include "libld.h"
-#include "msg.h"
-
-
-/*
- * With the 5.x compiler, stab.h changed struct nlist into
- * struct stab and got rid of it's embeded unions.
- */
-#if __SUNPRO_C >= 0x500 || defined(__GNUC__)
-#define nlist stab
-#else
-#define n_strx n_un.n_strx
-#endif
-
-
-/*
- * Data structure that holds persistent data that sbfocus_symbol & sbfocus_close
- * needs. Passing in a pointer to this struct makes them re-entrant.
- */
-typedef struct sbld_tag {
- FILE *fd;
- int failed;
-} *Sbld, Sbld_rec;
-
-
-extern Sbld_rec sb_data;
-extern const char *out_fname, *in_fname;
-extern Half out_e_type;
-extern void sbfocus_symbol(Sbld, const char *, const char *,
- const char *);
-
-#if !defined(_ELF64)
-
-/*
- * holds information needed by sbfocus_symbol and sbfocus_close.
- */
-Sbld_rec sb_data = { NULL, 0 };
-
-/*
- * holds information out the output file being created.
- */
-const char *out_fname = NULL;
-const char *in_fname = NULL; /* current input file */
-Half out_e_type = ET_NONE;
-
-/*
- * Signal handler is called when a SIGPIPE is encountered. This would
- * happen in case `sbfocus' did not exist and `ld' is writing down a
- * pipe with no reader. Trap signal and set failed field so that no
- * more subsequent writes occur.
- */
-static void
-sigpipe_handler()
-{
- sb_data.failed = 1;
-}
-
-/*
- * sbfocus_symbol() will write one symbol to a pipe that has the program
- * "sbfocus" at the receiving end. If the program has not been started yet,
- * it is started, and the pipe established. "sbfocus" is started with the
- * function arguments "type" and "name" as its arguments, in that order.
- *
- * sbfocus_symbol() should be called with four arguments:
- * data Pointer to a Sbld struct that the caller has allocated in
- * permanent storage. It must be the same struct for all related
- * calls to sbfocus_symbol().
- * name This is the string name of the library/executable being built.
- * type A string, should be one of:
- * "-x": Building an executable or shared object
- * "-r": Concatenating object files
- * symbol The string that should be written to "sbfocus". If this
- * argument is NULL "sbfocus" is started, but no symbol is
- * written to it.
- */
-void
-sbfocus_symbol(Sbld data, const char *name, const char *type,
- const char *symbol)
-{
- int fd[2], err;
-
- if (data->failed) {
- return;
- }
-
- (void) signal(SIGPIPE, (void (*)(int)) sigpipe_handler);
-
- if (data->fd == NULL) {
- data->failed = 0;
- (void) pipe(fd);
-
- switch (fork()) {
- case -1:
- err = errno;
- (void) fprintf(stderr, MSG_INTL(MSG_SYS_FORK),
- in_fname, strerror(err),
- MSG_INTL(MSG_STAB_NOSBROW));
- data->failed = 1;
- (void) close(fd[0]);
- (void) close(fd[1]);
- return;
-
- /*
- * Child process
- */
- case 0:
- (void) close(fd[1]);
- (void) dup2(fd[0], fileno(stdin));
- (void) close(fd[0]);
- (void) execlp(MSG_ORIG(MSG_STR_SBFOCUS),
- MSG_ORIG(MSG_STR_SBFOCUS), type, name, 0);
-
- err = errno;
- (void) fprintf(stderr, MSG_INTL(MSG_SYS_EXEC),
- in_fname, MSG_ORIG(MSG_STR_SBFOCUS),
- strerror(err), MSG_INTL(MSG_STAB_NOSBROW));
- exit(-1);
-
- /*
- * Parent process
- */
- default:
- (void) close(fd[0]);
- data->fd = fdopen(fd[1], MSG_ORIG(MSG_STR_W));
- break;
- }
- }
- if (symbol != NULL) {
- (void) fputs(symbol, data->fd);
- (void) putc('\n', data->fd);
- }
-}
-#endif /* !defined(_ELF64) */
-
-
-static Xword
-pass1_stabindex(const Elf_Data *s_data, const Elf_Data *str_data,
- const size_t cwd_len, const size_t name_len)
-{
- struct nlist *elem;
- struct nlist *last = NULL;
- size_t i;
- size_t str_offset = 0;
- size_t new_size = 0;
- size_t first_object = 1;
- size_t any_obj = 0;
- size_t num_elem;
- /*
- * The processing of the stab table happens in two passes.
- *
- * first pass: calculate if any change is needed and if so, how much
- * the string table needs to be expanded by.
- */
- num_elem = s_data->d_size / sizeof (struct nlist);
- for (i = 0; i < num_elem; i++) {
- char *str;
-
- elem = (struct nlist *)s_data->d_buf + i;
- switch (elem->n_type) {
- case 0:
- if (last)
- str_offset += last->n_value;
- last = elem;
- break;
- case N_OBJ:
- str = (char *)str_data->d_buf + str_offset +
- elem->n_strx;
-
- if ((*str == '\0') && first_object) {
- /*
- * This is a 'CWD' N_OBJ
- *
- * we only record the 'cwd' once in each
- * stringtable. so - we only need to add
- * it's length once to the new_size
- */
- if (any_obj == 0) {
- any_obj++;
- new_size += cwd_len + 1;
- } /* if */
- first_object = 0;
- } /* if */
- else if (*str == '\0') {
- /*
- * This is a 'object_name' N_OBJ
- */
- new_size += name_len + 1;
- first_object = 1;
- } /* else if */
- break;
- default:
- /* no-op */
- break;
- } /* switch */
- } /* for */
- /*LINTED*/
- return ((Xword) new_size);
-} /* pass1_stabindex */
-
-
-static int
-pass2_stabindex(Elf_Data *s_data, Elf_Data *str_data, const char *name,
- size_t name_len, size_t cwd_pos, size_t free_pos)
-{
- struct nlist *elem;
- struct nlist *last = NULL;
- size_t i;
- size_t str_offset = 0;
- size_t first_object = 1;
- size_t num_elem;
- /*
- * The processing of the stab table happens in two passes.
- *
- * first pass: calculate if any change is needed and if so, how much
- * the string table needs to be expanded by.
- */
- num_elem = s_data->d_size / sizeof (struct nlist);
- for (i = 0; i < num_elem; i++) {
- char *str;
-
- elem = (struct nlist *)s_data->d_buf + i;
- switch (elem->n_type) {
- case 0:
- if (last)
- str_offset += last->n_value;
- last = elem;
- break;
- case N_OBJ:
- str = (char *)str_data->d_buf + str_offset +
- elem->n_strx;
-
- if ((*str == '\0') && first_object) {
- /*
- * This is a 'CWD' N_OBJ
- *
- * We point it at the CWD entry that we've
- * already placed in the new string_table.
- */
- /*LINTED*/
- elem->n_strx = (unsigned)(cwd_pos - str_offset);
- first_object = 0;
- } /* if */
- else if (*str == '\0') {
- /*
- * This is a 'object_name' N_OBJ.
- *
- * Append the object name to the string table
- * and set the elem->n_un.n_strx to point
- * to it.
- */
- (void) strcpy((char *)str_data->d_buf +
- free_pos, name);
- /*LINTED*/
- elem->n_strx = (unsigned)(free_pos -
- str_offset);
- free_pos += name_len + 1;
- first_object = 1;
- } /* if */
- break;
- default:
- break;
- } /* switch */
- } /* for */
-
- /*LINTED*/
- last->n_value = (unsigned)(str_data->d_size - str_offset);
-
- return (1);
-} /* pass2_stabindex() */
-
-
-/*
- * find_scn()
- *
- * Find a section in elf that matches the supplied section name,
- * type, and flags.
- *
- * Returns:
- * section number if found
- * 0 - if no matching section found
- * -1 - if error
- *
- * If shdr is a non-null pointer it will be set to the section header
- * that was found.
- */
-static size_t
-find_scn(Elf *elf, const char *elf_strtab, const char *name,
- const Word sh_type, const Xword sh_flags, Elf_Scn **ret_scn)
-{
- Elf_Scn *scn = NULL;
- Shdr *scn_shdr;
-
- while ((scn = elf_nextscn(elf, scn)) != 0) {
- if ((scn_shdr = elf_getshdr(scn)) == NULL)
- return ((size_t)-1);
- if ((scn_shdr->sh_type == sh_type) &&
- (scn_shdr->sh_flags == sh_flags) &&
- (strcmp(elf_strtab + scn_shdr->sh_name, name) == 0)) {
- size_t scn_ndx;
- /*
- * we've got a match
- */
- if ((scn_ndx = elf_ndxscn(scn)) == SHN_UNDEF)
- return ((size_t)-1);
- if (ret_scn)
- *ret_scn = scn;
- return (scn_ndx);
- } /* if */
- } /* while */
-
- /*
- * no match found
- */
- return (0);
-} /* find_scn() */
-
-
-static Elf_Data *
-get_str_data(Elf *elf, const char *strtab, const char *name, Shdr *shdr)
-{
- Elf_Scn *str_scn;
- Elf_Data *str_data;
-
- /*
- * The stab's string table can be found through the
- * shdr->sh_link value.
- */
- if (shdr->sh_link == 0) {
- /*
- * Normally the sh_link field should point to the
- * required strtab. But if it's not filled in (which
- * means something goofed somewhere) we will try to look
- * it up from the elf file itself.
- */
- size_t strscn_ndx;
-
- strscn_ndx = find_scn(elf, strtab, name, SHT_STRTAB,
- shdr->sh_flags, &str_scn);
- if (strscn_ndx == 0) {
- (void) fprintf(stderr, MSG_INTL(MSG_STAB_MISTBL),
- in_fname);
- return ((Elf_Data *)S_ERROR);
- } else if (strscn_ndx == (size_t)-1) {
- (void) fprintf(stderr, MSG_INTL(MSG_STAB_BADTBL),
- in_fname);
- return ((Elf_Data *)S_ERROR);
- }
- } else {
- if ((str_scn = elf_getscn(elf, shdr->sh_link)) == NULL) {
- (void) fprintf(stderr, MSG_INTL(MSG_ELF_GETSCN),
- in_fname, elf_errmsg(0));
- return ((Elf_Data *)S_ERROR);
- }
- }
-
- if ((str_data = elf_getdata(str_scn, NULL)) == NULL) {
- (void) fprintf(stderr, MSG_INTL(MSG_ELF_GETDATA), in_fname,
- elf_errmsg(0));
- return ((Elf_Data *)S_ERROR);
- }
-
- return (str_data);
-}
-
-
-
-
/*
- * We examine all the stab's looking for pairs of N_OBJ's who's
- * string pointers (elem->n_un.n_strx) points to a null string.
- * When we find a pair we set the first string pointing to the
- * CWD and we set the second string to the file object name (*name).
+ * The sharable object /usr/lib/libldstab.so.1 is a link-editor
+ * support library that was used to compress the stab table by
+ * eliminating duplicate include file entries. The link-editor would
+ * load it by default, unless the user explicitly supplied a support
+ * library via the ld -S option. We publically documented this in the
+ * Solaris Linkers and Libraries Manual (LLM), stating that users
+ * who supply their own support libraries should also explicitly
+ * add '-S libldstab.so.1' to their link commands in order to retain
+ * the functionality it supplied.
*
- * The stab's string table will have to be expanded to hold
- * these new enties.
- */
-static void
-process_stabindex(Elf *elf, const char *elf_strtab, const char *strtab_name,
- Shdr *shdr, Elf_Data *s_data)
-{
- Elf_Data *str_data;
- static char *cwd = NULL;
- static size_t cwd_len;
- size_t new_size;
- size_t cwd_pos;
- size_t name_len;
- Elf_Void *data;
-
- if ((str_data = get_str_data(elf, elf_strtab, strtab_name,
- shdr)) == (Elf_Data *)S_ERROR)
- return;
-
- if (cwd == NULL) {
- if ((cwd = getcwd(NULL, MAXPATHLEN)) == NULL) {
- (void) fprintf(stderr, MSG_INTL(MSG_SYS_GETCWD),
- in_fname, strerror(errno));
- return;
- }
- cwd_len = strlen(cwd);
- }
- name_len = strlen(in_fname);
-
- new_size = pass1_stabindex(s_data, str_data, cwd_len, name_len);
-
- if (new_size == 0)
- /* no changes are needed */
- return;
- /*
- * The .stab.index data buffer must be updated so a new copy is
- * allocated. The original is read-only.
- */
- if ((data = malloc(s_data->d_size)) == 0)
- return;
- (void) memcpy(data, s_data->d_buf, s_data->d_size);
- s_data->d_buf = data;
-
- /*
- * Allocate a new .stab.indexstr that is big enough to hold the new
- * entries that we will need to place into it.
- *
- * Then append the 'cwd' onto the end of the current data.
- */
- if ((data = malloc(str_data->d_size + new_size)) == 0)
- return;
- (void) memcpy(data, str_data->d_buf, str_data->d_size);
- cwd_pos = str_data->d_size;
- (void) strcpy((char *)data + cwd_pos, cwd);
- str_data->d_buf = data;
- str_data->d_size = str_data->d_size + new_size;
-
- (void) pass2_stabindex(s_data, str_data, in_fname, name_len, cwd_pos,
- cwd_pos + cwd_len + 1);
-}
-
-
-static void
-process_stabsbfocus(Elf *elf, const char *elf_strtab,
- const char *strtab_name, Shdr *shdr, Elf_Data *s_data,
- const char *out_name, Half etype)
-{
- Elf_Data *str_data;
- struct nlist *elem, *last = NULL;
- size_t i, str_offset = 0, num_elem;
-
- if ((str_data = get_str_data(elf, elf_strtab, strtab_name,
- shdr)) == (Elf_Data *)S_ERROR)
- return;
-
- num_elem = s_data->d_size / sizeof (struct nlist);
- for (i = 0; i < num_elem; i++) {
- const char *type, *str;
-
- elem = (struct nlist *)s_data->d_buf + i;
- switch (elem->n_type) {
- case 0:
- if (last)
- str_offset += last->n_value;
- last = elem;
- break;
- case N_BROWS:
- str = (char *)str_data->d_buf + elem->n_strx +
- str_offset;
- if (etype == ET_REL)
- type = MSG_ORIG(MSG_STR_DASHR);
- else
- type = MSG_ORIG(MSG_STR_DASHX);
- sbfocus_symbol(&sb_data, out_name, type, str);
- break;
- default:
- /* no-op */
- break;
- }
- }
-}
-
-
-/* ARGSUSED2 */
-void
-#if defined(_ELF64)
-ld_start64(const char *out_name, const Half etype, const char *caller)
-#else
-ld_start(const char *out_name, const Half etype, const char *caller)
-#endif
-{
- out_fname = out_name;
- out_e_type = etype;
-}
-
-
-/* ARGSUSED1 */
-void
-#if defined(_ELF64)
-ld_file64(const char *name, const Elf_Kind kind, int flags, Elf *elf)
-#else
-ld_file(const char *name, const Elf_Kind kind, int flags, Elf *elf)
-#endif
-{
- in_fname = name;
-}
-
-
-/*
- * ld_section()
+ * The original libldstab.so worked by forking a child process running
+ * a program named sbfocus. sbfocus was delivered with the Sun
+ * compilers, and was expected to be found in the users PATH.
+ * As the compilers and the OSnet are delivered on disjoint schedules,
+ * this division never worked very well. Modern versions of the
+ * compilers supply their own support libraries directly as needed, and
+ * no longer deliver a program named sbfocus. The link-editor no longer
+ * loads libldstab.so.1 by default, and it is no longer documented in the LLM.
*
- * Args:
- * name - pointer to name of current section being processed.
- * shdr - pointer to Section Header of current in-file being
- * processed.
- * s_data - pointer to Section Data structure of current in-file
- * being processed.
- * elf - pointer to elf structure for current in-file being
- * processed
+ * The current version of /usr/lib/libldstab.so.1 is a stub that exists
+ * solely for backward compatibility. In the case where an existing
+ * Makefile still follows the old advice in the LLM and supplies
+ * '-S libldstab.so.1' to the link-editor command line, this object
+ * will be loaded. It specifies a support library version of
+ * LD_SUP_VNONE, which indicates to the link-editor that it is
+ * not needed and should be quietly unloaded. In this way, we
+ * preserve the old documented interface without undue overhead.
*/
-/* ARGSUSED2 */
-void
-#if defined(_ELF64)
-ld_section64(const char *scn_name, Shdr *shdr, Word scnndx,
-#else
-ld_section(const char *scn_name, Shdr *shdr, Word scnndx,
-#endif
- Elf_Data *s_data, Elf *elf)
-{
- Ehdr *ehdr;
- Elf_Data *str_data;
- Elf_Scn *str_scn;
- char *strtab;
- ehdr = elf_getehdr(elf);
- if ((ehdr->e_type != ET_DYN) && (shdr->sh_type == SHT_PROGBITS)) {
- /*
- * this is a minor optimization for speed. If it's not a
- * stab string we aren't going to strcmp() it.
- */
- if ((scn_name[1] == 's') &&
- (scn_name[2] == 't') &&
- (scn_name[3] == 'a') &&
- (scn_name[4] == 'b')) {
- Word shstrndx;
- /*
- * If 'extended sections' are in use, then
- * e_shstrndx == Shdr[0].sh_link
- */
- if (ehdr->e_shstrndx == SHN_XINDEX) {
- Elf_Scn *scn0;
- Shdr *shdr0;
- scn0 = elf_getscn(elf, 0);
- shdr0 = elf_getshdr(scn0);
- shstrndx = shdr0->sh_link;
- } else
- shstrndx = ehdr->e_shstrndx;
-
- str_scn = elf_getscn(elf, shstrndx);
- str_data = elf_getdata(str_scn, NULL);
- strtab = str_data->d_buf;
+#include <stdio.h>
+#include <link.h>
+#include "libld.h"
- if (strcmp(scn_name, MSG_ORIG(MSG_SCN_STAB)) == 0) {
- /*
- * Process .stab
- */
- process_stabsbfocus(elf, strtab,
- MSG_ORIG(MSG_SCN_STABSTR), shdr,
- s_data, out_fname, out_e_type);
- } else if (strcmp(scn_name,
- MSG_ORIG(MSG_SCN_STABINDEX)) == 0) {
- /*
- * Process .stab.index
- */
- process_stabindex(elf, strtab,
- MSG_ORIG(MSG_SCN_STABINDEXSTR), shdr,
- s_data);
- } else if (strcmp(scn_name,
- MSG_ORIG(MSG_SCN_STABSBFOCUS)) == 0) {
- /*
- * Process .stab.sbfocus
- */
- process_stabsbfocus(elf, strtab,
- MSG_ORIG(MSG_SCN_STABSBFOCUSTR), shdr,
- s_data, out_fname, out_e_type);
- }
- }
- }
-}
-/*
- * Null atexit() routine, causes dlsym() to pass and thus no dlerror() message
- * generation.
- */
/* ARGSUSED */
-void
+uint_t
#if defined(_ELF64)
-ld_atexit64(int status)
+ld_version64(uint_t version)
#else
-ld_atexit(int status)
+ld_version(uint_t version)
#endif
{
+ /* LD_SUP_VNONE tells libld.so to ignore this support library */
+ return (LD_SUP_VNONE);
}
-
-#if !defined(_ELF64)
-/*
- * Messaging support - funnel everything through dgettext().
- */
-
-const char *
-_libldstab_msg(Msg mid)
-{
- return (dgettext(MSG_ORIG(MSG_SUNW_OST_SGS), MSG_ORIG(mid)));
-}
-#endif
diff --git a/usr/src/cmd/sgs/libldstab/common/stab.h b/usr/src/cmd/sgs/libldstab/common/stab.h
deleted file mode 100644
index 65a5bf840f..0000000000
--- a/usr/src/cmd/sgs/libldstab/common/stab.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- */
-
-/*
- * THIS FILE IS NOW THE MASTER stab.h FILE, A DUPLICATE OF stab.h MAY BE
- * MAINTAINED BY SPARCompilers
- *
- * KEEP IN SYNC
- *
- */
-
-/* FILE NOT I18N */
-
-/*
- * This file gives definitions supplementing <a.out.h>
- * for debugging symbol table entries.
- * These entries must have one of the N_STAB bits on,
- * and are subject to relocation according to the masks in <a.out.h>
- * on 4.x (stabs not relocated on SVR4).
- */
-
-#ifndef _STAB_H
-#define _STAB_H
-
-#if (!defined(_a_out_h) && !defined(_A_OUT_H)) || defined(HP_UX)
-/* this file also contains fragments of a.out.h relevant to
- * support of stab processing within ELF files
- * (when a.out.h is not available)
- */
-struct stab {
- unsigned n_strx; /* index into file string table */
- unsigned char n_type; /* type flag (N_TEXT,..) */
- char n_other; /* used by N_SLINE stab */
- short n_desc; /* see stabs documentation */
- unsigned n_value; /* value of symbol (or sdb offset) */
-};
-
-/* patchtypes for N_PATCH stab (n_desc field) */
-
-#define P_BITFIELD 0x1
-#define P_SPILL 0x2
-#define P_SCOPY 0x3
-
-/* markers for N_CODETAG stab (n_other field) */
-
-#define CODETAG_BITFIELD 0x1 /* load/store of a bit field */
-#define CODETAG_SPILL 0x2 /* spill of registers */
-#define CODETAG_SCOPY 0x3 /* structure copy load/store */
-#define CODETAG_FSTART 0x4 /* points to first inst of new frame (0==leaf)*/
-#define CODETAG_END_CTORS 0x5 /* end of calls to super-class constructors */
-/* UNUSED 0x6 DW_ATCF_SUN_branch_target in dwarf, not used in stabs */
-#define CODETAG_STACK_PROBE 0x7 /* marks insns which probe the stack memory */
-
-/*
- * Simple values for n_type.
- */
-#define N_UNDF 0x0 /* undefined */
-#define N_ABS 0x2 /* absolute */
-#define N_TEXT 0x4 /* text */
-#define N_DATA 0x6 /* data */
-#define N_BSS 0x8 /* bss */
-#define N_COMM 0x12 /* common (internal to ld) */
-#define N_FN 0x1f /* file name symbol */
-
-#define N_EXT 01 /* external bit, or'ed in */
-#define N_TYPE 0x1e /* mask for all the type bits */
-
-#endif
-
-/*
- * maximum length of stab string before using continuation stab.
- * (this is just a suggested limit), assembler has no limit.
- */
-
-#define MAX_STAB_STR_LEN 250
-
-/*
- * for symbolic debuggers:
- */
-#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
-#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
-#define N_FUN 0x24 /* procedure: name,,0,linenumber,0 */
-#define N_OUTL 0x25 /* outlined func: name,,0,linenumber,0 */
-#define N_STSYM 0x26 /* static symbol: name,,0,type,0 or section relative */
-#define N_TSTSYM 0x27 /* thread static symbol: Ttdata.data */
-#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,0 or section relative */
-#define N_TLCSYM 0x29 /* thread local symbol: Ttbss.bss */
-#define N_MAIN 0x2a /* name of main routine : name,,0,0,0 */
-#define N_ROSYM 0x2c /* ro_data: name,,0,type,0 or section relative */
-#define N_FLSYM 0x2e /* fragmented data: name,,0,type,0 */
-#define N_TFLSYM 0x2f /* thread fragmented data: name,,0,type,0 */
-#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */
-#define N_CMDLINE 0x34 /* command line info */
-#define N_OBJ 0x38 /* object file path or name */
-#define N_OPT 0x3c /* compiler options */
-#define N_RSYM 0x40 /* register sym: name,,0,type,register */
-#define N_SLINE 0x44 /* src line: 0,,0,linenumber,function relative */
-#define N_XLINE 0x45 /* h.o. src line: 0,,0,linenumber>>16,0 */
-#define N_ILDPAD 0x4c /* now used as ild pad stab value=strtab delta
- was designed for "function start.end" */
-#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
-#define N_ENDM 0x62 /* last stab emitted for object module */
-#define N_SO 0x64 /* source file name: name,,0,0,0 */
-#define N_MOD 0x66 /* f90 module: name,,0,0,0 */
-#define N_EMOD 0x68 /* end of f90 module: name,,0,0,0 */
-#define N_READ_MOD 0x6a /* use of f90 module: name;locallist,,0,0,0 */
-#define N_ALIAS 0x6c /* alias name: name,,0,0,0 */
-#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
-#define N_BINCL 0x82 /* header file: name,,0,0,0 */
-#define N_SOL 0x84 /* #included file name: name,,0,0,0 */
-#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
-#define N_EINCL 0xa2 /* end of include file */
-#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,0 */
-#define N_SINCL 0xa6 /* shared include file */
-#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,function relative */
-#define N_EXCL 0xc2 /* excluded include file */
-#define N_USING 0xc4 /* C++ using command */
-#define N_ISYM 0xc6 /* position independent type symbol, internal */
-#define N_ESYM 0xc8 /* position independent type symbol, external */
-#define N_PATCH 0xd0 /* Instruction to be ignored by run-time checking. */
-#define N_CONSTRUCT 0xd2 /* C++ constructor call. */
-#define N_DESTRUCT 0xd4 /* C++ destructor call. */
-#define N_CODETAG 0xd8 /* Generic code tag */
-#define N_FUN_CHILD 0xd9 /* Identifies a child function */
-#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,function relative */
-#define N_BCOMM 0xe2 /* begin common: name,, */
-#define N_TCOMM 0xe3 /* begin task common: name,, */
-#define N_ECOMM 0xe4 /* end task_common/common: name,, */
-#define N_XCOMM 0xe6 /* excluded common block */
-#define N_ECOML 0xe8 /* end common (local name): ,,address */
-#define N_WITH 0xea /* pascal with statement: type,,0,0,offset */
-#define N_LENG 0xfe /* second stab entry with length information */
-
-/*
- * for analyzer (cache profile feedback support)
- */
-#define N_CPROF 0xf0 /* annotation for cache profile feedback */
-
-/*
- * n_descr values used in N_CPROF stabs. The n_descr field of
- * an N_CPROF stab identifies the type of table whose location
- * is defined by the N_CPROF stab.
- */
-typedef enum n_cprof_instr_type_t {
- N_CPROF_INSTR_TYPE_LOAD=0, /* profiled load ops */
- N_CPROF_INSTR_TYPE_STORE, /* profiled store ops */
- N_CPROF_INSTR_TYPE_PREFETCH, /* profiled prefetch ops */
- N_CPROF_INSTR_TYPE_BRTARGET, /* branch target locations */
- N_CPROF_INSTR_TYPE_NTYPES /* number of types */
-} n_cprof_instr_type_t;
-
-/*
- * for code browser only
- */
-#define N_BROWS 0x48 /* path to associated .cb file */
-
-/*
- * for functions -- n_other bits for N_FUN stab
- */
-#define N_FUN_PURE (1<<0)
-#define N_FUN_ELEMENTAL (1<<1)
-#define N_FUN_RECURSIVE (1<<2)
-
-/*
- * for variables -- n_other bits for N_LSYM, N_GSYM, N_LCSYM, N_STSYM, ...
- */
-#define N_SYM_OMP_TLS (1<<3)
-
-/*
- * Optional language designations for N_SO (n_desc field)
- */
-#define N_SO_AS 1 /* Assembler */
-#define N_SO_C 2 /* C */
-#define N_SO_ANSI_C 3 /* ANSI C */
-#define N_SO_CC 4 /* C++ */
-#define N_SO_FORTRAN 5 /* Fortran 77 */
-#define N_SO_FORTRAN77 5 /* Fortran 77 */
-#define N_SO_PASCAL 6 /* Pascal */
-#define N_SO_FORTRAN90 7 /* Fortran 90 */
-#define N_SO_JAVA 8 /* Java */
-#define N_SO_C99 9 /* C99 */
-
-/*
- * Floating point type values (encoded in "R" type specification string)
- */
-#define NF_NONE 0 /* Undefined type */
-#define NF_SINGLE 1 /* Float IEEE 32 bit floating point */
-#define NF_DOUBLE 2 /* Double IEEE 64 bit floating point */
-#define NF_COMPLEX 3 /* Complex (2 32bit floats) */
-#define NF_COMPLEX16 4 /* Complex (2 64bit doubles) */
-#define NF_COMPLEX32 5 /* Complex (2 128bit long doubles) */
-#define NF_LDOUBLE 6 /* Long double 128 bit floating point */
-#define NF_INTERARITH 7 /* Interval (2 32bit floats) */
-#define NF_DINTERARITH 8 /* Interval (2 64bit doubles) */
-#define NF_QINTERARITH 9 /* Interval (2 128bit long doubles) */
-#define NF_IMAGINARY 10 /* Imaginary (1 32bit floats) */
-#define NF_DIMAGINARY 11 /* Imaginary (1 64bit doubles) */
-#define NF_QIMAGINARY 12 /* Imaginary (1 128bit long doubles) */
-
-#endif
-
-