diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:31:57 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:31:57 +0000 |
commit | 09e967c2d732783b2579e4e120cd9b608404cb00 (patch) | |
tree | 8d2783a6a7e33608c6012efd6a88b8f5694df81d /mdk-stage1/dietlibc/libdl/dlerror.c | |
parent | 18fcff49d3c836697d3b75a3d01d31c700e69974 (diff) | |
download | drakx-09e967c2d732783b2579e4e120cd9b608404cb00.tar drakx-09e967c2d732783b2579e4e120cd9b608404cb00.tar.gz drakx-09e967c2d732783b2579e4e120cd9b608404cb00.tar.bz2 drakx-09e967c2d732783b2579e4e120cd9b608404cb00.tar.xz drakx-09e967c2d732783b2579e4e120cd9b608404cb00.zip |
Merge from R9_0-AMD64, most notably:
- AMD64 support to insmod-busybox, minilibc, et al.
- Sync with insmod-modutils 2.4.19 something but everyone should use
dietlibc nowadays
- Factor out compilation and prefix with $(DIET) for dietlibc builds
- 64-bit & varargs fixes
Diffstat (limited to 'mdk-stage1/dietlibc/libdl/dlerror.c')
-rw-r--r-- | mdk-stage1/dietlibc/libdl/dlerror.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/mdk-stage1/dietlibc/libdl/dlerror.c b/mdk-stage1/dietlibc/libdl/dlerror.c index 1e31bae54..3fea0b75c 100644 --- a/mdk-stage1/dietlibc/libdl/dlerror.c +++ b/mdk-stage1/dietlibc/libdl/dlerror.c @@ -1,4 +1,55 @@ -const char *dlerror(void) -{ - return "HAE ?!?"; + +#include "_dl_int.h" + +#ifdef __DIET_LD_SO__ +static unsigned int _dl_error; +static const char*_dl_error_location; +static const char*_dl_error_data; +#else +#include <string.h> +unsigned int _dl_error; +const char*_dl_error_location; +const char*_dl_error_data; +#endif + +static struct _dl_err_msg { + char*msg; + int len; +} _dl_error_msg[]={ +#define MSG(n) { (n), sizeof((n))-1 } + MSG("can't open: "), /* 1 */ + MSG("can't stat: "), /* 2 */ + MSG("shared object is not position independent: "), /* 3 */ + MSG("can't resolve all symbols in: "), /* 4 */ + MSG("can't find symbol: "), /* 5 */ + MSG("invalid relocation type in: "), /* 6 */ + MSG("internal error: layout not yet supported: "), /* 7 */ +}; + +const char *dlerror(void) { + static char buf[1024],*p=buf; + register int l,len=sizeof(buf)-1; + if (_dl_error==0) return 0; + + buf[0]=0; + buf[len]=0; + --_dl_error; + + if (_dl_error>=(sizeof(_dl_error_msg)/sizeof(struct _dl_err_msg))) + return "HAE ?!?"; + + if (_dl_error_location) { + l=strlen(_dl_error_location); + strncpy(p,_dl_error_location,len); len-=l; p+=l; + strncpy(p,": ",len); len-=2; p+=2; + } + l=_dl_error_msg[_dl_error].len; + strncpy(p,_dl_error_msg[_dl_error].msg,len); len-=l; p+=l; + strncpy(p,_dl_error_data,len); + + _dl_error_location=0; + _dl_error_data=""; + _dl_error=0; + + return buf; } |