summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-aout
diff options
context:
space:
mode:
authormckay <mckay@FreeBSD.org>1998-08-22 15:51:41 +0000
committermckay <mckay@FreeBSD.org>1998-08-22 15:51:41 +0000
commitbb26cf57dc7014c6e70c48ee6a73b23dadf400b0 (patch)
tree4584c9dc5c62188097d2786b2f2e3b848ceac6bc /libexec/rtld-aout
parentacd489515b1141170b910267880678ded29de0e4 (diff)
downloadFreeBSD-src-bb26cf57dc7014c6e70c48ee6a73b23dadf400b0.zip
FreeBSD-src-bb26cf57dc7014c6e70c48ee6a73b23dadf400b0.tar.gz
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.
Diffstat (limited to 'libexec/rtld-aout')
-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 4ae4fa6..5e7843e 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;
}
OpenPOWER on IntegriCloud