ICU-20938 Add --skip-dll-export option to genccode to prevent exporting statically linked ICU data from executables.
This commit is contained in:
parent
edf3f9c727
commit
76f190024d
@ -69,6 +69,7 @@ enum {
|
||||
#ifdef CAN_GENERATE_OBJECTS
|
||||
kOptObject,
|
||||
kOptMatchArch,
|
||||
kOptSkipDllExport,
|
||||
#endif
|
||||
kOptFilename,
|
||||
kOptAssembly
|
||||
@ -82,8 +83,9 @@ static UOption options[]={
|
||||
UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF("entrypoint", 'e', UOPT_REQUIRES_ARG),
|
||||
#ifdef CAN_GENERATE_OBJECTS
|
||||
/*5*/UOPTION_DEF("object", 'o', UOPT_NO_ARG),
|
||||
/*6*/UOPTION_DEF("object", 'o', UOPT_NO_ARG),
|
||||
UOPTION_DEF("match-arch", 'm', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF("skip-dll-export", '\0', UOPT_NO_ARG),
|
||||
#endif
|
||||
UOPTION_DEF("filename", 'f', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF("assembly", 'a', UOPT_REQUIRES_ARG)
|
||||
@ -127,7 +129,8 @@ main(int argc, char* argv[]) {
|
||||
fprintf(stderr,
|
||||
"\t-o or --object write a .obj file instead of .c\n"
|
||||
"\t-m or --match-arch file.o match the architecture (CPU, 32/64 bits) of the specified .o\n"
|
||||
"\t ELF format defaults to i386. Windows defaults to the native platform.\n");
|
||||
"\t ELF format defaults to i386. Windows defaults to the native platform.\n"
|
||||
"\t--skip-dll-export Don't export the ICU data entry point symbol (for use when statically linking)\n");
|
||||
#endif
|
||||
fprintf(stderr,
|
||||
"\t-f or --filename Specify an alternate base filename. (default: symbolname_typ)\n"
|
||||
@ -193,7 +196,8 @@ main(int argc, char* argv[]) {
|
||||
options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL,
|
||||
options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL,
|
||||
NULL,
|
||||
0);
|
||||
0,
|
||||
!options[kOptSkipDllExport].doesOccur);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -775,7 +775,8 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
|
||||
(optMatchArch[0] == 0 ? NULL : optMatchArch),
|
||||
NULL,
|
||||
gencFilePath,
|
||||
sizeof(gencFilePath));
|
||||
sizeof(gencFilePath),
|
||||
TRUE);
|
||||
pkg_destroyOptMatchArch(optMatchArch);
|
||||
#if U_PLATFORM_IS_LINUX_BASED
|
||||
result = pkg_generateLibraryFile(targetDir, mode, gencFilePath);
|
||||
|
@ -878,7 +878,8 @@ writeObjectCode(
|
||||
const char *optMatchArch,
|
||||
const char *optFilename,
|
||||
char *outFilePath,
|
||||
size_t outFilePathCapacity) {
|
||||
size_t outFilePathCapacity,
|
||||
UBool optWinDllExport) {
|
||||
/* common variables */
|
||||
char buffer[4096], entry[96]={ 0 };
|
||||
FileStream *in, *out;
|
||||
@ -888,6 +889,8 @@ writeObjectCode(
|
||||
uint16_t cpu, bits;
|
||||
UBool makeBigEndian;
|
||||
|
||||
(void)optWinDllExport; /* unused except Windows */
|
||||
|
||||
/* platform-specific variables and initialization code */
|
||||
#ifdef U_ELF
|
||||
/* 32-bit Elf file header */
|
||||
@ -1254,12 +1257,17 @@ writeObjectCode(
|
||||
uprv_memset(&symbolNames, 0, sizeof(symbolNames));
|
||||
|
||||
/* write the linker export directive */
|
||||
uprv_strcpy(objHeader.linkerOptions, "-export:");
|
||||
length=8;
|
||||
uprv_strcpy(objHeader.linkerOptions+length, entry);
|
||||
length+=entryLength;
|
||||
uprv_strcpy(objHeader.linkerOptions+length, ",data ");
|
||||
length+=6;
|
||||
if (optWinDllExport) {
|
||||
uprv_strcpy(objHeader.linkerOptions, "-export:");
|
||||
length=8;
|
||||
uprv_strcpy(objHeader.linkerOptions+length, entry);
|
||||
length+=entryLength;
|
||||
uprv_strcpy(objHeader.linkerOptions+length, ",data ");
|
||||
length+=6;
|
||||
}
|
||||
else {
|
||||
length=0;
|
||||
}
|
||||
|
||||
/* set the file header */
|
||||
objHeader.fileHeader.Machine=cpu;
|
||||
|
@ -100,6 +100,7 @@ writeObjectCode(
|
||||
const char *optMatchArch,
|
||||
const char *optFilename,
|
||||
char *outFilePath,
|
||||
size_t outFilePathCapacity);
|
||||
size_t outFilePathCapacity,
|
||||
UBool optWinDllExport);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user