summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/i386
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2005-04-14 00:04:50 +0000
committerpeter <peter@FreeBSD.org>2005-04-14 00:04:50 +0000
commit1fad513bbc7fd4cfb911a7e8b6bf217dc31f2606 (patch)
treed513c3626bbc01eb67bcd54c9d07e98feb61dd82 /libexec/rtld-elf/i386
parent3692814aa205daa2b88af6c8f8685de9694f0140 (diff)
downloadFreeBSD-src-1fad513bbc7fd4cfb911a7e8b6bf217dc31f2606.zip
FreeBSD-src-1fad513bbc7fd4cfb911a7e8b6bf217dc31f2606.tar.gz
Attempt to use i386_set_gsbase(), and gracefully fall back to LDT methods
if the direct access methods are not implemented.
Diffstat (limited to 'libexec/rtld-elf/i386')
-rw-r--r--libexec/rtld-elf/i386/reloc.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c
index 58cd38a..846b643 100644
--- a/libexec/rtld-elf/i386/reloc.c
+++ b/libexec/rtld-elf/i386/reloc.c
@@ -329,7 +329,7 @@ allocate_initial_tls(Obj_Entry *objs)
void* tls;
#ifndef COMPAT_32BIT
union descriptor ldt;
- int sel;
+ int error, sel;
#endif
/*
@@ -341,18 +341,21 @@ allocate_initial_tls(Obj_Entry *objs)
tls = allocate_tls(objs, NULL, 2*sizeof(Elf_Addr), sizeof(Elf_Addr));
#ifndef COMPAT_32BIT
- memset(&ldt, 0, sizeof(ldt));
- ldt.sd.sd_lolimit = 0xffff; /* 4G limit */
- ldt.sd.sd_lobase = ((Elf_Addr)tls) & 0xffffff;
- ldt.sd.sd_type = SDT_MEMRWA;
- ldt.sd.sd_dpl = SEL_UPL;
- ldt.sd.sd_p = 1; /* present */
- ldt.sd.sd_hilimit = 0xf; /* 4G limit */
- ldt.sd.sd_def32 = 1; /* 32 bit */
- ldt.sd.sd_gran = 1; /* limit in pages */
- ldt.sd.sd_hibase = (((Elf_Addr)tls) >> 24) & 0xff;
- sel = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
- __asm __volatile("movl %0,%%gs" : : "rm" ((sel << 3) | 7));
+ error = i386_set_gsbase(tls);
+ if (error) {
+ memset(&ldt, 0, sizeof(ldt));
+ ldt.sd.sd_lolimit = 0xffff; /* 4G limit */
+ ldt.sd.sd_lobase = ((Elf_Addr)tls) & 0xffffff;
+ ldt.sd.sd_type = SDT_MEMRWA;
+ ldt.sd.sd_dpl = SEL_UPL;
+ ldt.sd.sd_p = 1; /* present */
+ ldt.sd.sd_hilimit = 0xf; /* 4G limit */
+ ldt.sd.sd_def32 = 1; /* 32 bit */
+ ldt.sd.sd_gran = 1; /* limit in pages */
+ ldt.sd.sd_hibase = (((Elf_Addr)tls) >> 24) & 0xff;
+ sel = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
+ __asm __volatile("movl %0,%%gs" : : "rm" ((sel << 3) | 7));
+ }
#else
_amd64_set_gsbase(tls);
#endif
OpenPOWER on IntegriCloud