summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldso/include/dl-string.h12
-rw-r--r--ldso/ldso/arm/dl-sysdep.h1
-rw-r--r--ldso/ldso/cris/dl-sysdep.h2
-rw-r--r--ldso/ldso/frv/dl-sysdep.h2
-rw-r--r--ldso/ldso/i386/dl-sysdep.h2
-rw-r--r--ldso/ldso/m68k/dl-sysdep.h4
-rw-r--r--ldso/ldso/mips/dl-sysdep.h2
-rw-r--r--ldso/ldso/powerpc/dl-sysdep.h3
-rw-r--r--ldso/ldso/sh64/dl-sysdep.h2
-rw-r--r--ldso/ldso/x86_64/dl-sysdep.h2
10 files changed, 11 insertions, 21 deletions
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index ec098d2ca..a50cfd6b3 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -11,6 +11,14 @@
#include <dl-sysdep.h> /* for do_rem */
#include <features.h>
+/* provide some sane defaults */
+#ifndef do_rem
+# define do_rem(result, n, base) ((result) = (n) % (base))
+#endif
+#ifndef do_div_10
+# define do_div_10(result, remain) ((result) /= 10)
+#endif
+
static size_t _dl_strlen(const char * str);
static char *_dl_strcat(char *dst, const char *src);
static char * _dl_strcpy(char * dst,const char *src);
@@ -234,7 +242,7 @@ static __always_inline char * _dl_simple_ltoa(char * local, unsigned long i)
char temp;
do_rem(temp, i, 10);
*--p = '0' + temp;
- i /= 10;
+ do_div_10(i, temp);
} while (i > 0);
return p;
}
@@ -324,7 +332,7 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
do { \
do_rem(v, (X), 10); \
*--tmp2 = '0' + v; \
- (X) /= 10; \
+ do_div_10((X), v); \
} while ((X) > 0); \
_dl_write(2, tmp2, tmp1 - tmp2 + sizeof(tmp) - 1); \
}
diff --git a/ldso/ldso/arm/dl-sysdep.h b/ldso/ldso/arm/dl-sysdep.h
index 194fd2eb7..839e9276f 100644
--- a/ldso/ldso/arm/dl-sysdep.h
+++ b/ldso/ldso/arm/dl-sysdep.h
@@ -43,6 +43,7 @@ static inline unsigned long arm_modulus(unsigned long m, unsigned long p)
return m;
}
#define do_rem(result, n, base) ((result) = arm_modulus(n, base))
+#define do_div_10(result, remain) ((result) = (((result) - (remain)) / 2) * -(-1ul / 5ul))
/* Here we define the magic numbers that this dynamic loader should accept */
#define MAGIC1 EM_ARM
diff --git a/ldso/ldso/cris/dl-sysdep.h b/ldso/ldso/cris/dl-sysdep.h
index b5fa89035..b84dcad70 100644
--- a/ldso/ldso/cris/dl-sysdep.h
+++ b/ldso/ldso/cris/dl-sysdep.h
@@ -18,8 +18,6 @@
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 8192 bytes alignment */
#define PAGE_ALIGN 0xffffe000
#define ADDR_ALIGN 0x1fff
diff --git a/ldso/ldso/frv/dl-sysdep.h b/ldso/ldso/frv/dl-sysdep.h
index 158f6af04..131eb5fb5 100644
--- a/ldso/ldso/frv/dl-sysdep.h
+++ b/ldso/ldso/frv/dl-sysdep.h
@@ -65,8 +65,6 @@ struct funcdesc_value
extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 16KiB page alignment. Should perhaps be made dynamic using
getpagesize(), based on AT_PAGESZ from auxvt? */
#define PAGE_ALIGN 0xffffc000
diff --git a/ldso/ldso/i386/dl-sysdep.h b/ldso/ldso/i386/dl-sysdep.h
index 2ef94c95f..6d6039c83 100644
--- a/ldso/ldso/i386/dl-sysdep.h
+++ b/ldso/ldso/i386/dl-sysdep.h
@@ -25,8 +25,6 @@ do { \
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff
diff --git a/ldso/ldso/m68k/dl-sysdep.h b/ldso/ldso/m68k/dl-sysdep.h
index c11d2fbfe..4e5e09085 100644
--- a/ldso/ldso/m68k/dl-sysdep.h
+++ b/ldso/ldso/m68k/dl-sysdep.h
@@ -25,10 +25,6 @@ do { \
struct elf_resolve;
extern unsigned int _dl_linux_resolver (struct elf_resolve *, int);
-/* Define this because we do not want to call .udiv in the library.
- Not needed for m68k. */
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff
diff --git a/ldso/ldso/mips/dl-sysdep.h b/ldso/ldso/mips/dl-sysdep.h
index 63119aafb..77edcd921 100644
--- a/ldso/ldso/mips/dl-sysdep.h
+++ b/ldso/ldso/mips/dl-sysdep.h
@@ -63,8 +63,6 @@ unsigned long __dl_runtime_resolve(unsigned long sym_index,
struct elf_resolve;
void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy);
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff
diff --git a/ldso/ldso/powerpc/dl-sysdep.h b/ldso/ldso/powerpc/dl-sysdep.h
index 6f7bde147..a06aa8aff 100644
--- a/ldso/ldso/powerpc/dl-sysdep.h
+++ b/ldso/ldso/powerpc/dl-sysdep.h
@@ -67,9 +67,6 @@ struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
-
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff
diff --git a/ldso/ldso/sh64/dl-sysdep.h b/ldso/ldso/sh64/dl-sysdep.h
index 506e9ece2..f16885b23 100644
--- a/ldso/ldso/sh64/dl-sysdep.h
+++ b/ldso/ldso/sh64/dl-sysdep.h
@@ -25,8 +25,6 @@
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff
diff --git a/ldso/ldso/x86_64/dl-sysdep.h b/ldso/ldso/x86_64/dl-sysdep.h
index 9e2aff14f..202eab19d 100644
--- a/ldso/ldso/x86_64/dl-sysdep.h
+++ b/ldso/ldso/x86_64/dl-sysdep.h
@@ -41,8 +41,6 @@ do { \
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* 4096 bytes alignment */
#define PAGE_ALIGN 0xfffff000
#define ADDR_ALIGN 0xfff