]> granicus.if.org Git - icu/commitdiff
ICU-20938 Add --skip-dll-export option to genccode to prevent exporting statically...
authorEgor Pugin <egor.pugin@gmail.com>
Wed, 22 Jan 2020 19:55:54 +0000 (22:55 +0300)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Thu, 23 Jan 2020 20:00:29 +0000 (12:00 -0800)
icu4c/source/tools/genccode/genccode.c
icu4c/source/tools/pkgdata/pkgdata.cpp
icu4c/source/tools/toolutil/pkg_genc.cpp
icu4c/source/tools/toolutil/pkg_genc.h

index 91e94d7f5181c46c77fb27a7a7bdeaad2f3c331e..c5bbdf60d7d9103720d2d28137e136c54a983ba6 100644 (file)
@@ -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:
index 6406fcc7a5ba9f6482bc33c0111cea9b762508c9..ea75302a9849ba1ad9f106aba8f0ca1654e5241f 100644 (file)
@@ -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);
index 3f71e00cb64154eecf344d7f991466462624e2d6..a4b6d7aa931cfd0a146f21a8cc0067cab9e179d9 100644 (file)
@@ -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;
index 47e8304a6890c551d81088b451937da16191222b..b231aa6170c2874360cacda01a5fc379be3549ae 100644 (file)
@@ -100,6 +100,7 @@ writeObjectCode(
     const char *optMatchArch,
     const char *optFilename,
     char *outFilePath,
-    size_t outFilePathCapacity);
+    size_t outFilePathCapacity,
+    UBool optWinDllExport);
 
 #endif