[uClibc-cvs] svn commit: trunk/uClibc/ldso/include
andersen at uclibc.org
andersen at uclibc.org
Wed Apr 13 01:44:46 UTC 2005
Author: andersen
Date: 2005-04-12 19:44:45 -0600 (Tue, 12 Apr 2005)
New Revision: 10088
Log:
Rework the dl-startup.c ldso early debugging macros to be
significantly less horrible
Modified:
trunk/uClibc/ldso/include/dl-string.h
Changeset:
Modified: trunk/uClibc/ldso/include/dl-string.h
===================================================================
--- trunk/uClibc/ldso/include/dl-string.h 2005-04-12 23:56:55 UTC (rev 10087)
+++ trunk/uClibc/ldso/include/dl-string.h 2005-04-13 01:44:45 UTC (rev 10088)
@@ -46,10 +46,10 @@
static inline char * _dl_strcpy(char * dst,const char *src)
{
register char *ptr = dst;
-
+
dst--;src--;
while ((*++dst = *++src) != 0);
-
+
return ptr;
}
@@ -219,7 +219,8 @@
* or using long division */
static inline char *_dl_simple_ltoa(char * local, unsigned long i)
{
- /* 21 digits plus null terminator, good for 64-bit or smaller ints */
+ /* 20 digits plus a null terminator should be good for
+ * 64-bit or smaller ints (2^64 - 1)*/
char *p = &local[22];
*--p = '\0';
do {
@@ -233,7 +234,8 @@
static inline char *_dl_simple_ltoahex(char * local, unsigned long i)
{
- /* 21 digits plus null terminator, good for 64-bit or smaller ints */
+ /* 16 digits plus a leading "0x" plus a null terminator,
+ * should be good for 64-bit or smaller ints */
char *p = &local[22];
*--p = '\0';
do {
@@ -250,47 +252,61 @@
}
-#if defined(mc68000) || defined(__arm__) || defined(__mips__) || defined(__sh__) || defined(__powerpc__)
-/* On some arches constant strings are referenced through the GOT. */
-/* XXX Requires load_addr to be defined. */
-#define SEND_STDERR(X) \
- { const char *__s = (X); \
- if (__s < (const char *) load_addr) __s += load_addr; \
- _dl_write (2, __s, _dl_strlen (__s)); \
- }
+
+
+/* The following macros may be used in dl-startup.c to debug
+ * ldso before ldso has fixed itself up to make function calls */
+
+
+/* On some arches constant strings are referenced through the GOT.
+ * This requires that load_addr must already be defined... */
+#if defined(mc68000) || defined(__arm__) || defined(__mips__) \
+ || defined(__sh__) || defined(__powerpc__)
+# define CONSTANT_STRING_GOT_FIXUP(X) \
+ if ((X) < (const char *) load_addr) (X) += load_addr;
#else
-#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen(X));
+# define CONSTANT_STRING_GOT_FIXUP(X)
#endif
-/* Some targets may have to override this to something that doesn't
- reference constant strings through the GOT. This macro should be
- preferred over SEND_STDERR for constant strings before we complete
- bootstrap. */
-#ifndef SEND_EARLY_STDERR
-# define SEND_EARLY_STDERR(S) SEND_STDERR(S)
-#endif
-#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
- char tmp[22], *tmp1; \
- _dl_memset(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoahex( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
+#define SEND_STDERR(X) { \
+ const char *tmp1 = (X); \
+ CONSTANT_STRING_GOT_FIXUP(tmp1) \
+ _dl_write (2, tmp1, _dl_strlen(tmp1)); \
};
-#define SEND_NUMBER_STDERR(X, add_a_newline) { \
- char tmp[22], *tmp1; \
- _dl_memset(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoa( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
+#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
+ char tmp[26], v, *tmp2, *tmp1 = tmp; \
+ CONSTANT_STRING_GOT_FIXUP(tmp1) \
+ tmp2 = tmp1 + sizeof(tmp); \
+ *--tmp2 = '\0'; \
+ if (add_a_newline) *--tmp2 = '\n'; \
+ do { \
+ v = (X) & 0xf; \
+ if (v <= 0x09) \
+ *--tmp2 = '0' + v; \
+ else \
+ *--tmp2 = 'a' - 0x0a + v; \
+ (X) >>= 4; \
+ } while ((X) > 0); \
+ *--tmp2 = 'x'; \
+ *--tmp2 = '0'; \
+ _dl_write (2, tmp2, tmp1 - tmp2 + sizeof(tmp)); \
};
+#define SEND_NUMBER_STDERR(X, add_a_newline) { \
+ char tmp[26], v, *tmp2, *tmp1 = tmp; \
+ CONSTANT_STRING_GOT_FIXUP(tmp1) \
+ tmp2 = tmp1 + sizeof(tmp); \
+ *--tmp2 = '\0'; \
+ if (add_a_newline) *--tmp2 = '\n'; \
+ do { \
+ do_rem(v, (X), 10); \
+ *--tmp2 = '0' + v; \
+ (X) /= 10; \
+ } while ((X) > 0); \
+ _dl_write (2, tmp2, tmp1 - tmp2 + sizeof(tmp)); \
+};
+
#endif
More information about the uClibc-cvs
mailing list