• [PATCH] dxe3gen: add support for using an exports file.

    From [via djgpp@delorie.com]" @21:1/5 to All on Mon Jan 30 20:27:51 2023
    The patch inlined below (also attached for convenience) adds support for
    using an exports file to dxe3gen.

    The existing mechanism for exported symbols is through symbol prefixes,
    i.e. the -E and -X switches, but can be really hard to use especially if
    there are many symbols which don't necessarily share a common prefix, or
    if some of the symbols to exclude share the common prefix with symbols
    to export.

    The exports file is a plain text file with one symbol name at each line,
    like an exports file that can be used in macOS projects. No trailing or
    leading space/tab should be used in the file. A line starting with a '#' character is a comment line and will be ignored.

    The -E and -X switches are still supported, but those two are mutually exclusive.

    Eli, Juan, DJ: Please review. OK to apply?

    Index: dxe3gen.c ===================================================================
    RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v
    retrieving revision 1.27
    diff -u -p -r1.27 dxe3gen.c
    --- djgpp/src/dxe/dxe3gen.c 28 Jan 2023 14:10:03 -0000 1.27
    +++ djgpp/src/dxe/dxe3gen.c 30 Jan 2023 17:10:28 -0000
    @@ -277,6 +277,9 @@ static struct
    char *implib; /* name of import library */
    char *dxefile; /* the name of dxe file on command line */
    char *description; /* a description of the module */
    + unsigned int num_names; /* number of exported symbol names */
    + unsigned int max_names; /* maximal number of exported symbol names */ + char **export_names; /* exported symbol names */
    unsigned int num_prefix; /* number of exported prefixes */
    unsigned int max_prefix; /* maximal number of exported prefixes */
    char **export_prefix; /* exported symbol prefixes */
    @@ -307,6 +310,9 @@ static struct
    NULL,
    0,
    0,
    + NULL,
    + 0,
    + 0,
    NULL
    };

    @@ -319,6 +325,8 @@ static char *dxe_ar; /* default: "ar" */
    static char *dxe_ld; /* default: "ld" */
    /* linker script */
    static char *d
  • From [via djgpp@delorie.com]" @21:1/5 to All on Mon Jan 30 20:02:43 2023
    From: "Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]" <djgpp@delorie.com>
    Date: Mon, 30 Jan 2023 20:27:51 +0300

    The patch inlined below (also attached for convenience) adds support for using an exports file to dxe3gen.

    The existing mechanism for exported symbols is through symbol prefixes,
    i.e. the -E and -X switches, but can be really hard to use especially if there are many symbols which don't necessarily share a common prefix, or
    if some of the symbols to exclude share the common prefix with symbols
    to export.

    The exports file is a plain text file with one symbol name at each line,
    like an exports file that can be used in macOS projects. No trailing or leading space/tab should be used in the file. A line starting with a '#' character is a comment line and will be ignored.

    The -E and -X switches are still supported, but those two are mutually exclusive.

    Eli, Juan, DJ: Please review. OK to apply?

    LGTM, but why did you use binary mode for reading the exports file?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to All on Mon Jan 30 21:20:24 2023
    LGTM,

    OK, can apply tomorrow unless I get further reviews/objections.

    but why did you use binary mode for reading the exports file?

    Easier forme that way -- uniform parsing across platforms.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to Ozkan Sezer on Tue Jan 31 09:25:56 2023
    On 1/30/23, Ozkan Sezer <sezeroz@gmail.com> wrote:
    LGTM,

    OK, can apply tomorrow unless I get further reviews/objections.

    but why did you use binary mode for reading the exports file?

    Easier forme that way -- uniform parsing across platforms.

    Version 2 of patch attached. Changes:

    - Fixes segfault if the exports file has no newline at end
    - Reports missing exports in verbose mode.

    For convenience, an interdiff to first version is inlined below
    (cosmetic changes excluded.)

    --- dxe3gen.c~
    +++ dxe3gen.c
    @@ -519,7 +520,7 @@
    opt.export_names[opt.num_names++] = ptr++;

    loc1:
    - while (*ptr != '\r' && *ptr != '\n')
    + while (*ptr && *ptr != '\r' && *ptr != '\n')
    ++ptr;
    }
    }
    @@ -1277,9 +1278,12 @@
    BOOL ok = FALSE;
    for (j = 0; j < opt.num_names; j++)
    {
    + if (!opt.export_names[j])
    + continue;
    if (strcmp(opt.export_names[j], name) == 0)
    {
    ok = TRUE;
    + opt.export_names[j] = NULL;
    break;
    }
    }
    @@ -1310,6 +1314,15 @@
    }
    DEBUG_PRINT_SYMBOL_TABLE_EPILOG();

    + if (opt.verbose && opt.num_names && opt.num_names != dh.n_exp_syms)
    + {
    + for (j = 0; j < opt.num_names; j++)
    + {
    + if (opt.export_names[j])
    + printf("missing export: `%s'\n", opt.export_names[j]);
    + }
    + }
    +
    if (errcount)
    {
    fclose(outf);

    SW5kZXg6IGR4ZTNnZW4uYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0
  • From [via djgpp@delorie.com]" @21:1/5 to All on Tue Jan 31 11:43:00 2023
    LGTM,

    OK, can apply tomorrow unless I get further reviews/objections.

    but why did you use binary mode for reading the exports file?

    Easier forme that way -- uniform parsing across platforms.

    Version 2 of patch attached. Changes:

    - Fixes segfault if the exports file has no newline at end
    - Reports missing exports in verbose mode.

    For convenience, an interdiff to first version is inlined below
    (cosmetic changes excluded.)

    --- dxe3gen.c~
    +++ dxe3gen.c
    @@ -519,7 +520,7 @@
    opt.export_names[opt.num_names++] = ptr++;

    loc1:
    - while (*ptr != '\r' && *ptr != '\n')
    + while (*ptr && *ptr != '\r' && *ptr != '\n')
    ++ptr;
    }
    }
    @@ -1277,9 +1278,12 @@
    BOOL ok = FALSE;
    for (j = 0; j < opt.num_names; j++)
    {
    + if (!opt.export_names[j])
    + continue;
    if (strcmp(opt.export_names[j], name) == 0)
    {
    ok = TRUE;
    + opt.export_names[j] = NULL;
    break;
    }
    }
    @@ -1310,6 +1314,15 @@
    }
    DEBUG_PRINT_SYMBOL_TABLE_EPILOG();

    + if (opt.verbose && opt.num_names && opt.num_names != dh.n_exp_syms)
    + {
    + for (j = 0; j < opt.num_names; j++)
    + {
    + if (opt.export_names[j])
    + printf("missing export: `%s'\n", opt.export_names[j]);
    + }
    + }
    +
    if (errcount)
    {
    fclose(outf);

    Version 3 of the patch attached. Changes:

    - Leading or trailing whitespace in symbol name line are now tolerated.

    For convenience, an interdiff to version-2 is inlined below.

    --- dxe3gen.c~
    +++ dxe3gen.c
    @@ -503,25 +503,28 @@ static void process_exp_file(const char

    ptr = expfile;
    for (;;)
    {
    - while (*ptr == '\r' || *ptr == '\n')
    + while (*ptr == '\r' || *ptr == '\n' || *ptr == ' ' || *ptr == '\t')
    *ptr++ = '\0';

    if (!*ptr) break;

    if (*ptr == '#') /* comment */
    - goto loc1;
    + {
    + while (*ptr && *ptr != '\r' && *ptr != '\n')
    + ++ptr;
    + continue;
    + }

    if (opt.num_names >= opt.max_names)
    {
    opt.max_names += 16;
    opt.export_names = (char **)realloc(opt.export_names,
    opt.max_names * sizeof(char *));
    }
    opt.export_names[opt.num_names++] = ptr++;

    - loc1:
    - while (*ptr && *ptr != '\r' && *ptr != '\n')
    + while (*ptr && *ptr != '\r' && *ptr != '\n' && *ptr != ' ' && *ptr != '\t')
    ++ptr;
    }
    }


    If you guys don't catch any gotchas, I plan to apply this 3r version to cvs.

    ZHhlM2dlbjogYWRkIHN1cHBvcnQgZm9yIHVzaW5nIGFuIGV4cG9ydHMgZmlsZS4KCk5ldyBj
  • From [via djgpp@delorie.com]" @21:1/5 to All on Tue Jan 31 20:55:31 2023
    If you guys don't catch any gotchas, I plan to apply this 3r version to
    cvs.

    Question: Should I actually make any missing exports an error ?
    Patch inlined below.

    diff -up djgpp/src/dxe/dxe3gen.c~ djgpp/src/dxe/dxe3gen.c
    --- djgpp/src/dxe/dxe3gen.c~
    +++ djgpp/src/dxe/dxe3gen.c
    @@ -1317,12 +1317,14 @@ static int write_dxe(FILE *inf, FILE *ou
    }
    DEBUG_PRINT_SYMBOL_TABLE_EPILOG();

    - if (opt.verbose && opt.num_names && opt.num_names != dh.n_exp_syms)
    + if (opt.num_names && opt.num_names != dh.n_exp_syms)
    {
    + errcount = opt.num_names - dh.n_exp_syms;
    + fprintf(stderr, "Error: %d symbols to be exported are
    missing:\n", errcount);
    for (j = 0; j < opt.num_names; j++)
    {
    if (opt.export_names[j])
    - printf("missing export: `%s'\n", opt.export_names[j]);
    + fprintf(stderr, "missing export: `%s'\n", opt.export_names[j]);
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to All on Tue Jan 31 22:10:28 2023
    Question: Should I actually make any missing exports an error ?
    Patch inlined below.

    Unless this is a real problem,

    It is not,

    I'd say do this only under the verbose operation, i.e. optionally.

    i.e. error out only in verbose mode, which _can_ lead to problems?
    I' suggest inventing a new switch like --nomissing, what do you think?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to All on Tue Jan 31 21:33:41 2023
    From: "Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]" <djgpp@delorie.com>
    Date: Tue, 31 Jan 2023 22:10:28 +0300

    I'd say do this only under the verbose operation, i.e. optionally.

    i.e. error out only in verbose mode, which _can_ lead to problems?
    I' suggest inventing a new switch like --nomissing, what do you think?

    SGTM.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to djgpp@delorie.com on Tue Jan 31 23:16:15 2023
    On 1/31/23, Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com] <djgpp@delorie.com> wrote:
    From: "Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]"
    <djgpp@delorie.com>
    Date: Tue, 31 Jan 2023 22:10:28 +0300

    I'd say do this only under the verbose operation, i.e. optionally.

    i.e. error out only in verbose mode, which _can_ lead to problems?
    I' suggest inventing a new switch like --nomissing, what do you think?

    SGTM.


    OK, the patch is applied to cvs as r1.28: https://www.delorie.com/bin/cvsweb.cgi/djgpp/src/dxe/dxe3gen.c https://www.delorie.com/bin/cvsweb.cgi/djgpp/src/dxe/dxe3gen.c.diff?r1=1.27&r2=1.28

    Documentation and 2.06 changelog updates are TODO (unless someone beats
    me to it.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)