ICU-683 symbols collision fix for aix, solaris, linux

X-SVN-Rev: 2873
This commit is contained in:
Steven R. Loomis 2000-11-04 02:16:12 +00:00
parent b3a8a5cd7a
commit a86b703082
10 changed files with 157 additions and 20 deletions

View File

@ -165,10 +165,33 @@
# define NO_LIBRARY NULL
# define IS_LIBRARY(lib) ((lib)!=NULL)
#ifndef UDATA_DEBUG
# define LOAD_LIBRARY(path, basename) dlopen(path, RTLD_LAZY|RTLD_GLOBAL)
# define UNLOAD_LIBRARY(lib) dlclose(lib)
# define GET_LIBRARY_ENTRY(lib, entryName) dlsym(lib, entryName)
#else
void *LOAD_LIBRARY(const char *path, const char *basename)
{
void *rc;
rc = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
fprintf(stderr, "Load [%s|%s] -> %p\n", path, basename, rc);
return rc;
}
void UNLOAD_LIBRARY(void *lib)
{
dlclose(lib);
fprintf(stderr, "Unload [%p]\n", lib);
}
void * GET_LIBRARY_ENTRY(void *lib, const char *entryName)
{
void *rc;
rc = dlsym(lib, entryName);
fprintf(stderr, "Get[%p] %s->%p\n", lib, entryName, rc);
return rc;
}
#endif
/* End of dlopen or compatible functions */
#else /* unknown platform, no DLL implementation */
@ -481,6 +504,12 @@ offsetTOCLookupFn(const UDataMemory *pData,
const char *tocEntryName,
const char *dllEntryName,
UErrorCode *pErrorCode) {
#ifdef UDATA_DEBUG
fprintf(stderr, "offsetTOC[%p] looking for %s/%s\n",
pData,
tocEntryName,dllEntryName);
#endif
if(pData->toc!=NULL) {
const char *base=(const char *)pData->toc;
uint32_t *toc=(uint32_t *)pData->toc;
@ -500,11 +529,21 @@ offsetTOCLookupFn(const UDataMemory *pData,
if(uprv_strcmp(tocEntryName, base+toc[2*start])==0) {
/* found it */
#ifdef UDATA_DEBUG
fprintf(stderr, "Found: %p\n",(base+toc[2*start+1]));
#endif
return (const DataHeader *)(base+toc[2*start+1]);
} else {
#ifdef UDATA_DEBUG
fprintf(stderr, "Not found.\n");
#endif
return NULL;
}
} else {
#ifdef UDATA_DEBUG
fprintf(stderr, "returning header\n");
#endif
return pData->pHeader;
}
}
@ -514,6 +553,11 @@ pointerTOCLookupFn(const UDataMemory *pData,
const char *tocEntryName,
const char *dllEntryName,
UErrorCode *pErrorCode) {
#ifdef UDATA_DEBUG
fprintf(stderr, "ptrTOC[%p] looking for %s/%s\n",
pData,
tocEntryName,dllEntryName);
#endif
if(pData->toc!=NULL) {
const PointerTOCEntry *toc=(const PointerTOCEntry *)((const uint32_t *)pData->toc+2);
uint32_t start, limit, number;
@ -521,6 +565,12 @@ pointerTOCLookupFn(const UDataMemory *pData,
/* perform a binary search for the data in the common data's table of contents */
start=0;
limit=*(const uint32_t *)pData->toc; /* number of names in this table of contents */
#ifdef UDATA_DEBUG
fprintf(stderr, " # of ents: %d\n", limit);
fflush(stderr);
#endif
while(start<limit-1) {
number=(start+limit)/2;
if(uprv_strcmp(tocEntryName, toc[number].entryName)<0) {
@ -532,12 +582,23 @@ pointerTOCLookupFn(const UDataMemory *pData,
if(uprv_strcmp(tocEntryName, toc[start].entryName)==0) {
/* found it */
return normalizeDataPointer(toc[start].pHeader);
#ifdef UDATA_DEBUG
fprintf(stderr, "FOUND: %p\n",
normalizeDataPointer(toc[start].pHeader));
#endif
return normalizeDataPointer(toc[start].pHeader);
} else {
#ifdef UDATA_DEBUG
fprintf(stderr, "NOT found\n");
#endif
return NULL;
}
} else {
return pData->pHeader;
#ifdef UDATA_DEBUG
fprintf(stderr, "Returning header\n");
#endif
return pData->pHeader;
}
}
@ -556,7 +617,7 @@ dllTOCLookupFn(const UDataMemory *pData,
/* common library functions ------------------------------------------------- */
static UDataMemory commonICUData={ NULL };
static UDataMemory commonICUData={ NULL };
static void
setCommonICUData(UDataMemory *pData) {
@ -921,9 +982,17 @@ doOpenChoice(const char *path, const char *type, const char *name,
uprv_memset(&dataMemory, 0, sizeof(UDataMemory));
pathBuffer[0]=0;
pCommonData=openCommonData(&dataMemory, path, isICUData, pathBuffer, &errorCode);
#ifdef UDATA_DEBUG
fprintf(stderr, "commonData;%p\n", pCommonData);
fflush(stderr);
#endif
if(U_SUCCESS(errorCode)) {
/* look up the data piece in the common data */
pHeader=pCommonData->lookupFn(pCommonData, tocEntryName, dllEntryName, &errorCode);
#ifdef UDATA_DEBUG
fprintf(stderr, "Common found: %p\n", pHeader);
#endif
if(pHeader!=NULL) {
/* data found in the common data, test it */
if(pHeader->dataHeader.magic1==0xda && pHeader->dataHeader.magic2==0x27 &&
@ -949,9 +1018,15 @@ doOpenChoice(const char *path, const char *type, const char *name,
pEntryData->parent=pCommonData;
pEntryData->pHeader=pHeader;
pEntryData->flags=(pCommonData->flags&DATA_MEMORY_TYPE_MASK)|1UL<<DYNAMIC_DATA_MEMORY_SHIFT;
#ifdef UDATA_DEBUG
fprintf(stderr, " made data @%p\n", pEntryData);
#endif
return pEntryData;
} else {
/* the data is not acceptable, look further */
#ifdef UDATA_DEBUG
fprintf(stderr, "Not acceptable\n");
#endif
errorCode=U_INVALID_FORMAT_ERROR;
}
}
@ -970,6 +1045,10 @@ doOpenChoice(const char *path, const char *type, const char *name,
inBasename=findBasename(path);
}
#ifdef UDATA_DEBUG
fprintf(stderr, "looking for ind. file\n");
#endif
/* try path+basename+"_"+entryName first */
if(*inBasename!=0) {
suffix=strcpy_returnEnd(basename, inBasename);
@ -1068,7 +1147,7 @@ U_CAPI UDataMemory * U_EXPORT2
udata_open(const char *path, const char *type, const char *name,
UErrorCode *pErrorCode) {
#ifdef UDATA_DEBUG
fprintf(stderr, "udata_open(): Opening: %s . %s\n", name, type);
fprintf(stderr, "udata_open(): Opening: %s . %s\n", name, type);fflush(stderr);
#endif
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
@ -1085,6 +1164,10 @@ U_CAPI UDataMemory * U_EXPORT2
udata_openChoice(const char *path, const char *type, const char *name,
UDataMemoryIsAcceptable *isAcceptable, void *context,
UErrorCode *pErrorCode) {
#ifdef UDATA_DEBUG
fprintf(stderr, "udata_openChoice(): Opening: %s . %s\n", name, type);fflush(stderr);
#endif
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
return NULL;
} else if(name==NULL || *name==0 || isAcceptable==NULL) {
@ -1097,6 +1180,10 @@ udata_openChoice(const char *path, const char *type, const char *name,
U_CAPI void U_EXPORT2
udata_close(UDataMemory *pData) {
#ifdef UDATA_DEBUG
fprintf(stderr, "udata_close()\n");fflush(stderr);
#endif
if(pData!=NULL && IS_DATA_MEMORY_LOADED(pData)) {
unloadDataMemory(pData);
if(pData->flags&(1UL<<DYNAMIC_DATA_MEMORY_SHIFT)) {

View File

@ -3,7 +3,7 @@
## Copyright (c) 1999-2000, International Business Machines Corporation and
## others. All Rights Reserved.
##
## $Id: mh-aix,v 1.16 2000/10/16 18:05:34 yves Exp $
## $Id: mh-aix,v 1.17 2000/11/04 02:16:11 srl Exp $
## Commands to generate dependency files
GEN_DEPS.c= $(CC) -E -M $(DEFS) $(CPPFLAGS)
@ -95,4 +95,9 @@ LIBUSTDIO= -L$(top_builddir)/extra/ustdio -lustdio
@echo "Generating dependency information for $<"
@$(SHELL) -ec '$(GEN_DEPS.cc) $< > /dev/null 2>&1'
## BIR - bind with internal references [so app data and icu data doesn't collide]
BIR_LDFLAGS= -E$(NAME).map -bnoexpall
BIR_CPPFLAGS= -DU_HAVE_BIND_INTERNAL_REFERENCES
BIR_DEPS= $(NAME).map
## End Aix-specific setup

View File

@ -3,7 +3,7 @@
## Copyright (c) 1999-2000, International Business Machines Corporation and
## others. All Rights Reserved.
##
## $Id: mh-linux,v 1.22 2000/10/18 20:35:21 yves Exp $
## $Id: mh-linux,v 1.23 2000/11/04 02:16:11 srl Exp $
## Commands to generate dependency files
GEN_DEPS.c= $(CC) -E -MM $(DEFS) $(CPPFLAGS)
@ -84,13 +84,13 @@ LIBUSTDIO= -L$(top_builddir)/extra/ustdio -lustdio
%.d: $(srcdir)/%.c
@echo "Generating dependency information for $<"
@$(SHELL) -ec '$(GEN_DEPS.c) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'
%.d: $(srcdir)/%.cpp
@echo "Generating dependency information for $<"
@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'
## Versioned libraries rules
@ -100,5 +100,16 @@ LIBUSTDIO= -L$(top_builddir)/extra/ustdio -lustdio
%.$(SO): %.$(SO).$(SO_TARGET_VERSION_MAJOR)
$(RM) $@ && ln -s $*.$(SO).$(SO_TARGET_VERSION) $@
## Bind internal references
# LDflags that pkgdata will use
BIR_LDFLAGS= -Wl,-Bsymbolic
# CPPflags for genccode/gencmn
BIR_CPPFLAGS= -DU_HAVE_BIND_INTERNAL_REFERENCES
# Dependencies [i.e. map files] for the final library
BIR_DEPS=
## End Linux-specific setup

View File

@ -3,7 +3,7 @@
## Copyright (c) 1999-2000, International Business Machines Corporation and
## others. All Rights Reserved.
##
## $Id: mh-solaris,v 1.20 2000/10/17 16:52:58 yves Exp $
## $Id: mh-solaris,v 1.21 2000/11/04 02:16:11 srl Exp $
## Flags for position independent code
SHAREDLIBCFLAGS = -KPIC
@ -94,4 +94,8 @@ LIBUSTDIO= -L$(top_builddir)/extra/ustdio -lustdio
%.$(SO): %.$(SO).$(SO_TARGET_VERSION_MAJOR)
$(RM) $@ && ln -s $*.$(SO).$(SO_TARGET_VERSION) $@
#
BIR_LDFLAGS= -Wl,-M,$(NAME).map -Wl,-B,symbolic -Wl,-B,eliminate
BIR_CPPFLAGS= -DU_HAVE_BIND_INTERNAL_REFERENCES
BIR_DEPS= $(NAME).map
## End Solaris-specific setup

View File

@ -572,6 +572,7 @@ void TestAppData()
{
UResourceBundle *icu, *app;
UResourceBundle *tmp = NULL;
UResourceBundle *tmp2 = NULL;
const UChar *appString;
const UChar *icuString;
@ -590,6 +591,8 @@ void TestAppData()
log_err("%s:%d: Couldn't open root ICU bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("Open icu root: %s size_%d\n", u_errorName(status), ures_getSize(icu)); */
status = U_ZERO_ERROR;
app = ures_open(testPath, "root", &status);
if(U_FAILURE(status))
@ -597,6 +600,7 @@ void TestAppData()
log_err("%s:%d: Couldn't open app ICU bundle [%s]- %s", __FILE__, __LINE__, testPath, u_errorName(status));
return;
}
/* log_info("Open app: %s, size %d\n", u_errorName(status), ures_getSize(app)); */
tmp = ures_getByKey(icu, "Version", tmp, &status);
if(U_FAILURE(status))
@ -611,25 +615,30 @@ void TestAppData()
log_err("%s:%d: Couldn't get string from Version string from ICU root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("icuString=%p - %s\n", icuString, austrdup(icuString)); */
tmp = ures_getByKey(app, "Version", tmp, &status);
tmp2 = ures_getByKey(app, "Version", tmp2, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
log_err("%s:%d: Couldn't get Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
appString = ures_getString(tmp, &len, &status);
appString = ures_getString(tmp2, &len, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get string from Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("appString=%p - %s\n", appString, austrdup(appString)); */
if(!u_strcmp(icuString, appString))
{
log_err("%s:%d: Error! Expected ICU and App root version strings to be DIFFERENT but they are both %s\n", __FILE__, __LINE__, austrdup(appString));
log_err("%s:%d: Error! Expected ICU and App root version strings to be DIFFERENT but they are both %s and %s\n", __FILE__, __LINE__, austrdup(icuString),
austrdup(appString));
}
else
{
@ -638,6 +647,7 @@ void TestAppData()
}
ures_close(tmp);
ures_close(tmp2);
ures_close(icu);
ures_close(app);

View File

@ -24,7 +24,7 @@ CLEANFILES = *~ $(DEPS) $(RES_FILES) $(TEST_FILES)
TARGET = genccode
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil $(BIR_CPPFLAGS)
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
ENABLE_RPATH = @ENABLE_RPATH@

View File

@ -66,6 +66,8 @@ main(int argc, char* argv[]) {
/* read command line options */
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
#ifndef U_HAVE_BIND_INTERNAL_REFERENCES
if( (options[4].doesOccur) && uprv_strcmp(options[4].value, "icudata")) /* be consistent with gencmn! */
{
uprv_strcpy(symPrefix, options[4].value);
@ -75,6 +77,9 @@ main(int argc, char* argv[]) {
{
symPrefix[0] = 0;
}
#else
symPrefix[0] = 0;
#endif
/* error handling, printing usage message */
if(argc<0) {

View File

@ -32,7 +32,7 @@ LINK = $(LINK.c)
endif
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil $(BIR_CPPFLAGS)
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
ENABLE_RPATH = @ENABLE_RPATH@

View File

@ -105,6 +105,7 @@ main(int argc, char* argv[]) {
options[7].value=DATA_TYPE;
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
#ifndef U_HAVE_BIND_INTERNAL_REFERENCES
/* if it is ICU data.. no prefix. */
if(!uprv_strcmp(options[6].value, COMMON_DATA_NAME))
{
@ -115,6 +116,9 @@ main(int argc, char* argv[]) {
uprv_strcpy(symPrefix, options[6].value);
uprv_strcat(symPrefix, "_");
}
#else
symPrefix[0] = 0;
#endif
/* error handling, printing usage message */
if(argc<0) {

View File

@ -153,6 +153,8 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
T_FileStream_writeLine(makefile, tmp);
sprintf(tmp, "TOCOBJ= %s_dat%s \n\n", o->shortName,OBJ_SUFFIX);
T_FileStream_writeLine(makefile, tmp);
sprintf(tmp, "TOCSYM= %s_dat \n\n", o->shortName);
T_FileStream_writeLine(makefile, tmp);
T_FileStream_writeLine(makefile, "BASE_OBJECTS= $(TOCOBJ) ");
@ -165,8 +167,8 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
T_FileStream_writeLine(makefile,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n");
#ifdef HPUX
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES)\n"
"\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ)\n"
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES) $(BIR_DEPS)\n"
"\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ) $(BIR_LDFLAGS)\n"
"\t-ls -l $@\n\n");
T_FileStream_writeLine(makefile, "$(TEMP_DIR)/hpux_junk_obj.cpp:\n"
@ -176,8 +178,8 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
" $(COMPILE.cc) -o $@ $<\n"
"\n");
#else
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(LISTFILES)\n"
"\t$(SHLIB.c) -o $@ $(OBJECTS)\n"
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(LISTFILES) $(BIR_DEPS)\n"
"\t$(SHLIB.c) -o $@ $(OBJECTS) $(BIR_LDFLAGS)\n"
"\t-ls -l $@\n\n");
#endif
@ -187,6 +189,15 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(TARGET)\n"
"\t$(INSTALL-L) $(TARGETDIR)/$(TARGET) $(INSTALLTO)/$(TARGET)\n\n");
#ifdef U_SOLARIS
T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n");
#endif
#ifdef AIX
T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n");
#endif
*status = U_ZERO_ERROR;
}