scummvm random work
[patches.git] / uclibc-misc1.diff
CommitLineData
5e993f12 1Index: ldso/ldso/dl-startup.c
2===================================================================
3--- ldso/ldso/dl-startup.c (revision 16049)
4+++ ldso/ldso/dl-startup.c (working copy)
5@@ -259,7 +272,7 @@
6 rel_addr += relative_count * sizeof(ELF_RELOC);
7 }
8
9- rpnt = (ELF_RELOC *) DL_RELOC_ADDR(load_addr, rel_addr);
10+ rpnt = (ELF_RELOC *) rel_addr;
11 for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
12 reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset);
13 symtab_index = ELF_R_SYM(rpnt->r_info);
14Index: ldso/ldso/ldso.c
15===================================================================
16--- ldso/ldso/ldso.c (revision 16049)
17+++ ldso/ldso/ldso.c (working copy)
18@@ -113,7 +125,7 @@
19 for (j = 0; j < jm; ++j) {
20 void (*dl_elf_func) (void);
21 dl_elf_func = (void (*)(void)) (intptr_t) addrs[j];
22- (*dl_elf_func) ();
23+ DL_CALL_FUNC_AT_ADDR (dl_elf_func, loadaddr, (void (*)(void)));
24 }
25 }
26 }
27@@ -141,7 +153,7 @@
28 while (i-- > 0) {
29 void (*dl_elf_func) (void);
30 dl_elf_func = (void (*)(void)) (intptr_t) array[i];
31- (*dl_elf_func) ();
32+ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void (*)(void)));
33 }
34 }
35 }
36@@ -168,7 +180,7 @@
37
38 dl_elf_func = (void (*)(void)) (intptr_t) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_FINI]);
39 _dl_if_debug_dprint("\ncalling FINI: %s\n\n", tpnt->libname);
40- (*dl_elf_func) ();
41+ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void)));
42 }
43 }
44 }
45@@ -852,7 +880,7 @@
46
47 _dl_if_debug_dprint("calling INIT: %s\n\n", tpnt->libname);
48
49- (*dl_elf_func) ();
50+ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void)));
51 }
52
53 _dl_run_init_array(tpnt);
54Index: ldso/ldso/dl-elf.c
55===================================================================
56--- ldso/ldso/dl-elf.c (revision 16049)
57+++ ldso/ldso/dl-elf.c (working copy)
58@@ -118,10 +118,9 @@
59 void
60 _dl_protect_relro (struct elf_resolve *l)
61 {
62- ElfW(Addr) start = (DL_RELOC_ADDR(l->loadaddr, l->relro_addr)
63- & ~(_dl_pagesize - 1));
64- ElfW(Addr) end = ((DL_RELOC_ADDR(l->loadaddr, l->relro_addr) + l->relro_size)
65- & ~(_dl_pagesize - 1));
66+ ElfW(Addr) base = (ElfW(Addr)) DL_RELOC_ADDR(l->loadaddr, l->relro_addr);
67+ ElfW(Addr) start = (base & ~(_dl_pagesize - 1));
68+ ElfW(Addr) end = ((base + l->relro_size) & ~(_dl_pagesize - 1));
69 _dl_if_debug_dprint("RELRO protecting %s: start:%x, end:%x\n", l->libname, start, end);
70 if (start != end &&
71 _dl_mprotect ((void *) start, end - start, PROT_READ) < 0) {
72@@ -628,7 +747,7 @@
73 }
74
75 _dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
76- _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(libaddr));
77+ _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr));
78 _dl_if_debug_dprint("\t\t entry: %x phdr: %x phnum: %x\n\n",
79 DL_RELOC_ADDR(lib_loadaddr, epnt->e_entry), tpnt->ppnt, tpnt->n_phent);
80
81@@ -822,7 +941,7 @@
82 int ret = 0;
83
84 for (l = _dl_loaded_modules; l != NULL; l = l->next) {
85- info.dlpi_addr = DL_LOADADDR_BASE(l->loadaddr);
86+ info.dlpi_addr = l->loadaddr;
87 info.dlpi_name = l->libname;
88 info.dlpi_phdr = l->ppnt;
89 info.dlpi_phnum = l->n_phent;
90Index: ldso/include/dl-defs.h
91===================================================================
92--- ldso/include/dl-defs.h (revision 16049)
93+++ ldso/include/dl-defs.h (working copy)
94@@ -140,4 +146,13 @@
95 && (!(TFROM) || (TFROM)->loadaddr < (TPNT)->loadaddr))
96 #endif
97
98+/* On some platforms, computing a pointer to function is more
99+ expensive than calling a function at a given address, so this
100+ alternative is provided. The function signature must be given
101+ within parentheses, as in a type cast. */
102+#ifndef DL_CALL_FUNC_AT_ADDR
103+# define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
104+ ((*SIGNATURE DL_ADDR_TO_FUNC_PTR ((ADDR), (LOADADDR)))(__VA_ARGS__))
105+#endif
106+
107 #endif /* _LD_DEFS_H */
108Index: ldso/include/dl-hash.h
109===================================================================
110--- ldso/include/dl-hash.h (revision 16049)
111+++ ldso/include/dl-hash.h (working copy)
112@@ -28,7 +28,7 @@
113 struct elf_resolve {
114 /* These entries must be in this order to be compatible with the interface used
115 by gdb to obtain the list of symbols. */
116- DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
117+ DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
118 char *libname; /* Absolute file name object was found in. */
119 ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
120 struct elf_resolve * next;
121Index: ldso/libdl/libdl.c
122===================================================================
123--- ldso/libdl/libdl.c (revision 16049)
124+++ ldso/libdl/libdl.c (working copy)
125@@ -378,10 +388,10 @@
126 if (tpnt->dynamic_info[DT_INIT]) {
127 void (*dl_elf_func) (void);
128 dl_elf_func = (void (*)(void)) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_INIT]);
129- if (dl_elf_func && *dl_elf_func != NULL) {
130+ if (dl_elf_func) {
131 _dl_if_debug_print("running ctors for library %s at '%p'\n",
132 tpnt->libname, dl_elf_func);
133- (*dl_elf_func) ();
134+ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void)));
135 }
136 }
137
138@@ -512,8 +539,8 @@
139 if (tpnt->dynamic_info[DT_FINI]) {
140 dl_elf_fini = (int (*)(void)) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_FINI]);
141 _dl_if_debug_print("running dtors for library %s at '%p'\n",
142- tpnt->libname, dl_elf_fini);
143- (*dl_elf_fini) ();
144+ tpnt->libname, dl_elf_fini);
145+ DL_CALL_FUNC_AT_ADDR (dl_elf_fini, tpnt->loadaddr, (int (*)(void)));
146 }
147 }
148
149@@ -660,7 +691,7 @@
150 _dl_if_debug_print("Module \"%s\" at %p\n",
151 tpnt->libname, DL_LOADADDR_BASE(tpnt->loadaddr));
152
153- if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf))
154+ if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf))
155 pelf = tpnt;
156 }
157