diff options
author | Peter Wemm <peter@FreeBSD.org> | 2005-04-14 00:04:50 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2005-04-14 00:04:50 +0000 |
commit | 8a477e0a7ab1c8414822f704e91f8c14dd2d239b (patch) | |
tree | d513c3626bbc01eb67bcd54c9d07e98feb61dd82 /libexec | |
parent | 4453c6dc677c67dba7385cbabd165577ceba8d1a (diff) | |
download | src-test2-8a477e0a7ab1c8414822f704e91f8c14dd2d239b.tar.gz src-test2-8a477e0a7ab1c8414822f704e91f8c14dd2d239b.zip |
Notes
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/i386/reloc.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 58cd38a93067..846b643caad0 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 |