Opened 19 years ago
Closed 18 years ago
#47 closed enhancement (fixed)
Create .sym files directly from emxomfld
Reported by: | Yuri Dario | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.2 |
Component: | emx | Version: | 0.6 |
Severity: | normal | Keywords: | |
Cc: |
Description
This patch allows emxomfld to produce a .sym file directly when -Zsym is specified on command line; also -Zmap is required.
To be complete it requires gcc.exe to pass -Zsym to emxomfld, actually not done.
Index: emxomfld.c =================================================================== --- emxomfld.c (revision 2508) +++ emxomfld.c (working copy) @@ -64,6 +64,9 @@ static const char *map_fname = NULL; static int map_flag = FALSE; +/* The sym file output flag, set by the -Zsym option. */ +static int sym_flag = FALSE; + /* The module definition file name (input), set if a file matching *.def is given on the command line. */ static const char *def_fname = NULL; @@ -1947,6 +1959,21 @@ free (t); } + /* Run mapsym if everything is ok until now. */ + if (rc == 0 && sym_flag == TRUE) + { + arg_init (TRUE); + put_arg ("mapsym.exe", TRUE, FALSE); + put_arg (map_fname, TRUE, FALSE); + arg_end (); + rc = emxomfld_spawn (command_line, "Mapsym"); + if (rc < 0) + { + perror ("emxomfld: mapsym"); + exit (2); + } + } + /* Return the return code of Linker or RC. */ return rc;
Attachments (1)
Change History (9)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
this patch will move the .sym file in the same directory of the map file, otherwise it is created in the current directory.
Index: emxomfld.c =================================================================== --- emxomfld.c (revision 2508) +++ emxomfld.c (working copy) @@ -64,6 +64,9 @@ static const char *map_fname = NULL; static int map_flag = FALSE; +/* The sym file output flag, set by the -Zsym option. */ +static int sym_flag = FALSE; + /* The module definition file name (input), set if a file matching *.def is given on the command line. */ static const char *def_fname = NULL; @@ -1417,6 +1420,8 @@ {"Zno-autoconv",0, 0, OPT_ZNO_AUTOCONV}, #define OPT_ZDLL_SEARCH 0x1008 {"Zdll-search",0, 0, OPT_ZDLL_SEARCH}, +#define OPT_ZSYM 0x1009 + {"Zsym",0, 0, OPT_ZSYM}, /* {"e", 1, 0, 'e'}, entry point */ {"i", 0, 0, 'i'}, {"o", 1, 0, 'o'}, @@ -1610,6 +1615,10 @@ opt_dll_search = 1; break; + case OPT_ZSYM: + sym_flag = TRUE; + break; + case OPT_LIBS_STATIC: opt_libs_static = 1; break; @@ -1659,6 +1668,9 @@ { t = xstrdup (output_fname); _remext (t); + //yd if module name has multiple dots, ilink will not add .map extension + //so I'll force it here + strcat( t, ".map"); map_fname = t; } @@ -1947,6 +1959,34 @@ free (t); } + /* Run mapsym if everything is ok until now. */ + if (rc == 0 && sym_flag == TRUE) + { + char* sym_name; + arg_init (TRUE); + put_arg ("mapsym.exe", TRUE, FALSE); + put_arg (map_fname, TRUE, FALSE); + arg_end (); + rc = emxomfld_spawn (command_line, "Mapsym"); + if (rc < 0) + { + perror ("emxomfld: mapsym"); + exit (2); + } + // .sym is created in current directory, move in same dir of .map + sym_name = xstrdup( _getname( map_fname)); + // if different, there is a path specified, need to move file + if (strcmp( sym_name, map_fname)) { + char* sym_name2 = xstrdup( map_fname); + _remext( sym_name); + strcat( sym_name, ".sym"); + _remext( sym_name2); + strcat( sym_name2, ".sym"); + unlink( sym_name2); + rename( sym_name, sym_name2); + } + } + /* Return the return code of Linker or RC. */ return rc;
comment:3 by , 19 years ago
rename doesn't move files, it only renames within filesystems and we could be linking standing on a readonly filesystem or one which is out of space. Please, chdir to the target directory and run mapsym from there. That means you'll have to fullpath (or something) both the names, if that's not already done. (Yes, I know there is code for the responsefile which puts it in the current dir, but that's no excuse for doing the wrong thing.)
comment:4 by , 19 years ago
Milestone: | libc-0.6.1 → libc-0.6.2 |
---|
comment:5 by , 19 years ago
This new code does it, and it is even simpler.
Index: emxomfld.c =================================================================== --- emxomfld.c (revision 2592) +++ emxomfld.c (working copy) @@ -64,6 +64,9 @@ static const char *map_fname = NULL; static int map_flag = FALSE; +/* The sym file output flag, set by the -Zsym option. */ +static int sym_flag = FALSE; + /* The module definition file name (input), set if a file matching *.def is given on the command line. */ static const char *def_fname = NULL; @@ -1163,7 +1166,6 @@ static void arg_init (int rsp) { - response_fname[0] = '\0'; if (response_fname[0] != '\0') { remove (response_fname); @@ -1425,6 +1427,8 @@ {"Zno-autoconv",0, 0, OPT_ZNO_AUTOCONV}, #define OPT_ZDLL_SEARCH 0x1008 {"Zdll-search",0, 0, OPT_ZDLL_SEARCH}, +#define OPT_ZSYM 0x1009 + {"Zsym",0, 0, OPT_ZSYM}, /* {"e", 1, 0, 'e'}, entry point */ {"i", 0, 0, 'i'}, {"o", 1, 0, 'o'}, @@ -1618,6 +1622,10 @@ opt_dll_search = 1; break; + case OPT_ZSYM: + sym_flag = TRUE; + break; + case OPT_LIBS_STATIC: opt_libs_static = 1; break; @@ -1958,6 +1966,35 @@ free (t); } + /* Run mapsym if everything is ok until now. */ + if (rc == 0 && sym_flag == TRUE) + { + char* cwd = getcwd( NULL, 0); + char map_fname_fullpath[_MAX_PATH]; + char map_fname_path[_MAX_PATH]; + char drive[_MAX_PATH], dir[_MAX_DIR]; + + // get absolute path of map file + _fullpath( map_fname_fullpath, map_fname, sizeof (map_fname_fullpath)); + // change working dir to map file directory + _splitpath( map_fname_fullpath, drive, dir, NULL, NULL); + strcat( drive, dir); + _chdir( drive); + // write .sym file in current directory + arg_init (TRUE); + put_arg ("mapsym.exe", TRUE, FALSE); + put_arg (map_fname_fullpath, TRUE, FALSE); + arg_end (); + rc = emxomfld_spawn (command_line, "Mapsym"); + if (rc < 0) + { + perror ("emxomfld: mapsym"); + exit (2); + } + // restore working directory + _chdir( cwd); + } + /* Return the return code of Linker or RC. */ return rc;
comment:6 by , 18 years ago
This new patch is required in order to support also watcom linker makefiles. MapSym.cmd from Odin32\tools\bin is required (attached).
Index: emxomfld.c =================================================================== --- emxomfld.c (revision 2701) +++ emxomfld.c (working copy) @@ -64,6 +64,9 @@ static const char *map_fname = NULL; static int map_flag = FALSE; +/* The sym file output flag, set by the -Zsym option. */ +static int sym_flag = FALSE; + /* The module definition file name (input), set if a file matching *.def is given on the command line. */ static const char *def_fname = NULL; @@ -1542,6 +1545,8 @@ {"Zno-autoconv",0, 0, OPT_ZNO_AUTOCONV}, #define OPT_ZDLL_SEARCH 0x1008 {"Zdll-search",0, 0, OPT_ZDLL_SEARCH}, +#define OPT_ZSYM 0x1009 + {"Zsym",0, 0, OPT_ZSYM}, /* {"e", 1, 0, 'e'}, entry point */ {"i", 0, 0, 'i'}, {"o", 1, 0, 'o'}, @@ -1736,6 +1741,10 @@ opt_dll_search = 1; break; + case OPT_ZSYM: + sym_flag = TRUE; + break; + case OPT_LIBS_STATIC: opt_libs_static = 1; break; @@ -2207,6 +2216,46 @@ free (t); } + /* Run mapsym if everything is ok until now. */ + if (rc == 0 && sym_flag == TRUE) + { + char* cwd = getcwd( NULL, 0); + char map_fname_fullpath[_MAX_PATH]; + char map_fname_path[_MAX_PATH]; + char drive[_MAX_PATH], dir[_MAX_DIR]; + + // get absolute path of map file + _fullpath( map_fname_fullpath, map_fname, sizeof (map_fname_fullpath)); + // change working dir to map file directory + _splitpath( map_fname_fullpath, drive, dir, NULL, NULL); + strcat( drive, dir); + _chdir( drive); + // write .sym file in current directory + arg_init (TRUE); + if (getenv("COMSPEC")) + put_arg (getenv("COMSPEC"), TRUE, FALSE); + else + put_arg ("cmd.exe", TRUE, FALSE); + put_arg ("/c", FALSE, FALSE); + put_arg ("mapsym.cmd", TRUE, FALSE); + if (!stricmp (linker_type, "WLINK")) + put_arg ("watcom", TRUE, FALSE); + else if (!stricmp (linker_type, "LINK386")) + put_arg ("link386", TRUE, FALSE); + else + put_arg ("vac3xx", TRUE, FALSE); + put_arg (map_fname_fullpath, TRUE, FALSE); + arg_end (); + rc = emxomfld_spawn (command_line, "Mapsym"); + if (rc < 0) + { + perror ("emxomfld: mapsym"); + exit (2); + } + // restore working directory + _chdir( cwd); + } + /* Return the return code of Linker or RC. */ return rc;
comment:7 by , 18 years ago
One more fix: response file is not always deleted.
Index: emxomfld.c =================================================================== --- emxomfld.c (revision 2701) +++ emxomfld.c (working copy) @@ -1176,8 +1180,10 @@ { if (response_fname[0] != '\0') { - remove (response_fname); - response_fname[0] = '\0'; + //YD reset name only if delete is successfull (e.g. do not erase if file still + //doesn't exist) + if (!remove (response_fname)) + response_fname[0] = '\0'; } command_line[0] = '\0'; line_len = 0;
comment:8 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I've applied the -Zsym changes. mapsym.cmd however cannot be shipped because it contains code which is (C) IBM (my fault). The response file cleanup thing, doesn't make sense so I haven't applied it.
This patch will update gcc specs file to pass -Zsym to linker.