Deleted Added
full compact
reloc.c (145593) reloc.c (147673)
1/*-
2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
1/*-
2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 145593 2005-04-27 13:17:23Z davidxu $
25 * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 147673 2005-06-29 23:15:36Z peter $
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

--- 288 unchanged lines hidden (view full) ---

322 obj->jmpslots_done = true;
323 return 0;
324}
325
326void
327allocate_initial_tls(Obj_Entry *objs)
328{
329 void* tls;
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

--- 288 unchanged lines hidden (view full) ---

322 obj->jmpslots_done = true;
323 return 0;
324}
325
326void
327allocate_initial_tls(Obj_Entry *objs)
328{
329 void* tls;
330 union descriptor ldt;
331 int error, sel;
332
333 /*
334 * Fix the size of the static TLS block by using the maximum
335 * offset allocated so far and adding a bit for dynamic modules to
336 * use.
337 */
338 tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
339 tls = allocate_tls(objs, NULL, 2*sizeof(Elf_Addr), sizeof(Elf_Addr));
330
331 /*
332 * Fix the size of the static TLS block by using the maximum
333 * offset allocated so far and adding a bit for dynamic modules to
334 * use.
335 */
336 tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
337 tls = allocate_tls(objs, NULL, 2*sizeof(Elf_Addr), sizeof(Elf_Addr));
340 error = i386_set_gsbase(tls);
341 if (error < 0) {
342 memset(&ldt, 0, sizeof(ldt));
343 ldt.sd.sd_lolimit = 0xffff; /* 4G limit */
344 ldt.sd.sd_lobase = ((Elf_Addr)tls) & 0xffffff;
345 ldt.sd.sd_type = SDT_MEMRWA;
346 ldt.sd.sd_dpl = SEL_UPL;
347 ldt.sd.sd_p = 1; /* present */
348 ldt.sd.sd_hilimit = 0xf; /* 4G limit */
349 ldt.sd.sd_def32 = 1; /* 32 bit */
350 ldt.sd.sd_gran = 1; /* limit in pages */
351 ldt.sd.sd_hibase = (((Elf_Addr)tls) >> 24) & 0xff;
352 sel = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
353 __asm __volatile("movl %0,%%gs" : : "rm" ((sel << 3) | 7));
354 }
338 i386_set_gsbase(tls);
355}
356
357/* GNU ABI */
358__attribute__((__regparm__(1)))
359void *___tls_get_addr(tls_index *ti)
360{
361 Elf_Addr** segbase;
362 Elf_Addr* dtv;

--- 18 unchanged lines hidden ---
339}
340
341/* GNU ABI */
342__attribute__((__regparm__(1)))
343void *___tls_get_addr(tls_index *ti)
344{
345 Elf_Addr** segbase;
346 Elf_Addr* dtv;

--- 18 unchanged lines hidden ---