aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-aout/rtld.c
diff options
context:
space:
mode:
authorStephen McKay <mckay@FreeBSD.org>1998-08-22 15:51:41 +0000
committerStephen McKay <mckay@FreeBSD.org>1998-08-22 15:51:41 +0000
commit166f84746d6c8e80a83cb1225bef286012000c8e (patch)
tree44c50b6b0d74c976e005fa0a68cbbeef001c73c7 /libexec/rtld-aout/rtld.c
parent9e802365601b64cd5ea24dbd9039346f6ffec203 (diff)
downloadsrc-166f84746d6c8e80a83cb1225bef286012000c8e.tar.gz
src-166f84746d6c8e80a83cb1225bef286012000c8e.zip
Pass me the pointy hat with the extra sequins. Just a moment, while I get
it to sit right... The __error() hack gave out the wrong address. It returned the address of errno in ld.so instead of the address of errno in the main program. Oops. The hack is now correct, just in time to be obsoleted by elf.
Notes
Notes: svn path=/head/; revision=38480
Diffstat (limited to 'libexec/rtld-aout/rtld.c')
-rw-r--r--libexec/rtld-aout/rtld.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c
index 4ae4fa612c09..5e7843ef3868 100644
--- a/libexec/rtld-aout/rtld.c
+++ b/libexec/rtld-aout/rtld.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: rtld.c,v 1.54 1998/06/07 03:53:06 brian Exp $
+ * $Id: rtld.c,v 1.55 1998/06/21 14:22:29 mckay Exp $
*/
#include <sys/param.h>
@@ -1605,6 +1605,8 @@ sym_addr(name)
}
+static int *p_errno; /* Pointer to errno variable in main program. */
+
/*
* Help old a.out binaries that are broken by the new errno macro. They
* can be missing __error() through no fault of their own. In particular,
@@ -1626,6 +1628,21 @@ lookup_errno_hack(sym, src_map, real_def_only)
return NULL;
/*
+ * Locate errno in the main program. If it's not there, NULL
+ * will be returned by our __error() substitute, and a core dump
+ * will follow. That's impossible, of course, since crt0.o always
+ * supplies errno.
+ */
+ smp = NULL;
+ np = lookup("_errno", &smp, 1);
+ if (np != NULL && smp != NULL) {
+ p_errno = (int *)(smp->som_addr + np->nz_value);
+#ifdef DEBUG
+ xprintf(" HACK: _errno at %p in %s\n", p_errno, smp->som_path);
+#endif
+ }
+
+ /*
* Specifically find the ld.so link map because most routines
* skip over it during normal operation.
*/
@@ -1634,10 +1651,7 @@ lookup_errno_hack(sym, src_map, real_def_only)
break;
/*
- * Actually, ld.so uses errno via the new macro, so it has a copy
- * of __error() lying around. The really neat but obscure hack
- * is to just use that one, but to be really clear about what
- * is going on, we use an explicit __error() substitute.
+ * Find our __error() substitute stashed here in ld.so.
*/
np = lookup("___error_unthreaded_hack", &smp, real_def_only);
if (np != NULL)
@@ -1661,7 +1675,7 @@ lookup_errno_hack(sym, src_map, real_def_only)
int *
__error_unthreaded_hack()
{
- return &errno;
+ return p_errno;
}