Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3588 → Rev 3589

/branches/dynload/uspace/app/dltest/dltest.c
58,21 → 58,10
*/
}
 
void __tls_get_addr(void)
{
}
 
int i = 1;
 
int main(int argc, char *argv[])
{
// kputint(-1);
/* kputint(0x100);
printf("Hello from dltest!\n");
kputint(0x200);
while(1);*/
printf("Hello from dltest!\n");
// while(1);
return 0;
}
 
/branches/dynload/uspace/lib/rtld/arch/ppc32/src/entry.s
34,9 → 34,10
 
## Rtld entry point
#
# r3 contains the PCB pointer
# r6 contains the PCB pointer
#
__entry:
# Pass the PCB pointer to __bootstrap as the first argument
# Since the first argument is passed in r3, no operation is needed.
# Pass the PCB pointer to __bootstrap as the first argument.
# The first argument is passed in r3.
mr %r3, %r6
bl __bootstrap
/branches/dynload/uspace/lib/rtld/arch/ppc32/src/runtime.c
50,23 → 50,23
) ;
}
 
typedef struct {
unsigned long int ti_module;
unsigned long int ti_offset;
} tls_index;
//typedef struct {
// unsigned long int ti_module;
// unsigned long int ti_offset;
//} tls_index;
 
void *__tls_get_addr(tls_index *ti);
//void *__tls_get_addr(tls_index *ti);
 
/* ppc32 uses TLS variant 1 */
void *__tls_get_addr(tls_index *ti)
{
uint8_t *tls;
///* ppc32 uses TLS variant 1 */
//void *__tls_get_addr(tls_index *ti)
//{
// uint8_t *tls;
//
// /* The TLS section is just after TCB */
// tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
//
// return tls + ti->ti_offset;
//}
 
/* The TLS section is just after TCB */
tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
 
return tls + ti->ti_offset;
}
 
/** @}
*/
/branches/dynload/uspace/lib/rtld/arch/ppc32/src/reloc.c
159,16 → 159,16
_plt_ent = plt+ 18;
_plt_table = plt + 18 + plt_n;
 
printf("parse relocation table\n");
DPRINTF("parse relocation table\n");
 
sym_table = m->dyn.sym_tab;
rt_entries = rt_size / sizeof(elf_rela_t);
str_tab = m->dyn.str_tab;
 
printf("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries);
DPRINTF("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries);
for (i = 0; i < rt_entries; ++i) {
printf("symbol %d: ", i);
DPRINTF("symbol %d: ", i);
r_offset = rt[i].r_offset;
r_info = rt[i].r_info;
r_addend = rt[i].r_addend;
176,7 → 176,7
sym_idx = ELF32_R_SYM(r_info);
sym = &sym_table[sym_idx];
 
printf("name '%s', value 0x%x, size 0x%x\n",
DPRINTF("name '%s', value 0x%x, size 0x%x\n",
str_tab + sym->st_name,
sym->st_value,
sym->st_size);
185,16 → 185,16
r_ptr = (uint32_t *)(r_offset + m->bias);
 
if (sym->st_name != 0) {
printf("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset);
DPRINTF("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset);
sym_def = symbol_def_find(str_tab + sym->st_name,
m, &dest);
printf("dest name: '%s'\n", dest->dyn.soname);
printf("dest bias: 0x%x\n", dest->bias);
DPRINTF("dest name: '%s'\n", dest->dyn.soname);
DPRINTF("dest bias: 0x%x\n", dest->bias);
if (sym_def) {
sym_addr = symbol_get_addr(sym_def, dest);
printf("symbol definition found, addr=0x%x\n", sym_addr);
DPRINTF("symbol definition found, addr=0x%x\n", sym_addr);
} else {
printf("symbol definition not found\n");
DPRINTF("symbol definition not found\n");
continue;
}
}
201,10 → 201,10
 
switch (rel_type) {
case R_PPC_JMP_SLOT:
printf("fixup R_PPC_JMP_SLOT (b+v)\n");
DPRINTF("fixup R_PPC_JMP_SLOT (b+v)\n");
pidx = (r_ptr - _plt_ent) / 2;
if (pidx >= plt_n) {
printf("error: proc index out of range\n");
DPRINTF("error: proc index out of range\n");
//kputint(0xee00ee0ee00);
while(1);
}
213,18 → 213,23
break;
 
case R_PPC_ADDR32:
printf("fixup R_PPC_ADDR32 (b+v+a)\n");
DPRINTF("fixup R_PPC_ADDR32 (b+v+a)\n");
*r_ptr = r_addend + sym_addr;
break;
case R_PPC_RELATIVE:
printf("fixup R_PPC_RELATIVE (b+a)\n");
DPRINTF("fixup R_PPC_RELATIVE (b+a)\n");
*r_ptr = r_addend + m->bias;
break;
case R_PPC_REL24:
printf("ignore R_PPC_REL24\n");
// printf("ignore R_PPC_REL24 at 0x%04x\n", (uintptr_t) r_ptr);
*r_ptr = (sym_addr + r_addend - (uint32_t)r_ptr) >> 2;
DPRINTF("fixup R_PPC_REL24 (s+a-p)>>2\n");
/*TODO*/
break;
default:
printf("unknown relocation type\n");
break;
}
}
 
/branches/dynload/uspace/lib/rtld/arch/ppc32/src/start.s
36,5 → 36,5
# Jump to a program entry point
program_run:
mtctr %r3
mr %r3, %r4 # Pass pcb to the entry point in %r3
mr %r6, %r4 # Pass pcb to the entry point in %r6
bctr
/branches/dynload/uspace/lib/libc/arch/ppc32/src/tls.c
1,5 → 1,6
/*
* Copyright (c) 2006 Ondrej Palkovsky
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
33,6 → 34,7
*/
 
#include <tls.h>
#include <align.h>
#include <sys/types.h>
 
tcb_t * __alloc_tls(void **data, size_t size)
45,5 → 47,36
tls_free_variant_1(tcb, size);
}
 
static void kputint(unsigned i)
{
asm volatile (
"mr %%r3, %0\n"
"li %%r9, 32\n"
"sc\n"
:
: "r" (i)
: "%r3","%r9"
) ;
}
 
typedef struct {
unsigned long int ti_module;
unsigned long int ti_offset;
} tls_index;
 
void *__tls_get_addr(tls_index *ti);
 
/* ppc32 uses TLS variant 1 */
void *__tls_get_addr(tls_index *ti)
{
uint8_t *tls;
 
/* The TLS section is just after TCB */
tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
 
/* Hopefully this is right. No docs found. */
return tls + ti->ti_offset + 32768;
}
 
/** @}
*/