Commit c5c25c11 authored by John van Groningen's avatar John van Groningen
Browse files

bug fix, fix generated options file for 32 bit windows, fix strlen call in...

bug fix, fix generated options file for 32 bit windows, fix strlen call in linker command size overflow test, add patching CLEANPATH,CLEANLIB and CLEANILIB using patchbin on windows, add patchbin and -O and -s to windows makefiles, prevent some c compiler warnings
parent 6f287349
Pipeline #51743 passed with stage
in 40 seconds
CC=gcc
CFLAGS=-pedantic -Wall -W
CFLAGS=-O -pedantic -Wall -W
CPPFLAGS=-DGNU_C -D_WINDOWS_ -DI486 -DA_64
clm: clm.o
$(CC) clm.o -o clm
$(CC) -s clm.o -o clm
clm.o: clm.c cachingcompiler.h
patch_bin: patch_bin.o
$(CC) -s patch_bin.o -o patch_bin
CC=gcc
CFLAGS=-pedantic -Wall -W
CFLAGS=-O -pedantic -Wall -W
CPPFLAGS=-DGNU_C -D_WINDOWS_ -DI486
clm: clm.o
$(CC) clm.o -o clm
$(CC) -s clm.o -o clm
clm.o: clm.c cachingcompiler.h
patch_bin: patch_bin.o
$(CC) -s patch_bin.o -o patch_bin
......@@ -96,11 +96,27 @@ extern char *getenv();
#endif
/* file and directory names which may be patched using patchbin */
#if defined (LINUX) || defined (_WINDOWS_)
# define QUOTE_MACRO(s) #s
# define CMD_LINE_ARG_TO_STR(s) QUOTE_MACRO(s)
# ifdef CLEANLIB
char _clean_lib_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANLIB %*&" CMD_LINE_ARG_TO_STR(CLEANLIB);
# else
char _clean_lib_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANLIB %*&.";
# endif
# ifdef CLEANPATH
char _clean_directory_list[PATH_LIST_STRING_SIZE]= "#$@CLEANPATH %*&" CMD_LINE_ARG_TO_STR(CLEANPATH);
# else
char _clean_directory_list[PATH_LIST_STRING_SIZE]= "#$@CLEANPATH %*&.";
# endif
char _clean_include_library_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANILIB %*&.";
# define clean_lib_directory (&_clean_lib_directory[16])
# define clean_directory_list (&_clean_directory_list[16])
# define clean_include_library_directory (&_clean_include_library_directory[16])
#endif
#if defined (I486) && !defined (LINUX)
# ifdef _WINDOWS_
char clean_lib_directory[PATH_NAME_STRING_SIZE] = "C:\\Clean";
char clean_directory_list[PATH_LIST_STRING_SIZE] = "C:\\Clean\\Libraries\\StdEnv";
char clean_include_library_directory[PATH_NAME_STRING_SIZE] = "C:\\Clean\\Libraries";
char assembler_file_name[PATH_NAME_STRING_SIZE] = "as.exe";
# ifndef USE_WLINK
# ifdef USE_CLEANLINKER
......@@ -122,27 +138,12 @@ extern char *getenv();
# endif
#else
# ifdef LINUX
# define QUOTE_MACRO(s) #s
# define CMD_LINE_ARG_TO_STR(s) QUOTE_MACRO(s)
# ifdef CLEANLIB
char _clean_lib_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANLIB %*&" CMD_LINE_ARG_TO_STR(CLEANLIB);
# else
char _clean_lib_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANLIB %*&.";
# endif
# ifdef CLEANPATH
char _clean_directory_list[PATH_LIST_STRING_SIZE]= "#$@CLEANPATH %*&" CMD_LINE_ARG_TO_STR(CLEANPATH);
# else
char _clean_directory_list[PATH_LIST_STRING_SIZE]= "#$@CLEANPATH %*&.";
# endif
char _clean_include_library_directory[PATH_NAME_STRING_SIZE] = "#$@CLEANILIB %*&.";
/* file and directory names which may be patched using patchbin */
char _assembler_file_name[PATH_NAME_STRING_SIZE] = "#$@ASSEMBLER %*&/usr/bin/as";
char _linker_file_name[PATH_NAME_STRING_SIZE] = "#$@LINKER %*&/usr/bin/gcc";
char _crt0_file_name [PATH_NAME_STRING_SIZE] = "#$@CRT %*&crt1.o";
char _ld_args [PATH_LIST_STRING_SIZE] = "#$@LDARGS %*&";
/* char _ld_args [PATH_LIST_STRING_SIZE] = "#$@LDARGS %*& --dynamic /lib/ld-linux.so.1"; */
# define clean_lib_directory (&_clean_lib_directory[16])
# define clean_directory_list (&_clean_directory_list[16])
# define clean_include_library_directory (&_clean_include_library_directory[16])
# define assembler_file_name (&_assembler_file_name[16])
# define linker_file_name (&_linker_file_name[16])
# define crt0_file_name (&_crt0_file_name[16])
......@@ -2644,6 +2645,7 @@ data [] =
/* null to .bss at 290 / 314 */
int_to_4_chars (0)/*bss_raw_data_size*/,
'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'/*null_aux_entry*/,
/* _heap_size at 306 / 330 */
int_to_4_chars (0), int_to_4_chars (4)/*heap_size_offset*/,
int_to_4_chars (0)/*heap_size_value*/,
......@@ -2651,17 +2653,21 @@ data [] =
int_to_2_chars (0)/*heap_size_type*/,
(char) 2/*heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*heap_size_n_aux_sections*/,
/* _ab_stack_size at 326 / 360 */
int_to_4_chars (0), int_to_4_chars (14)/*ab_stack_size_offset*/,
int_to_4_chars (0),
# ifdef A_64
int_to_4_chars (14)/*ab_stack_size_offset*/,
int_to_4_chars (8)/*ab_stack_size_value*/,
# else
int_to_4_chars (15)/*ab_stack_size_offset*/,
int_to_4_chars (4)/*ab_stack_size_value*/,
# endif
int_to_2_chars (2)/*ab_stack_size_section_n*/,
int_to_2_chars (0)/*ab_stack_size_type*/,
(char) 2/*ab_stack_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*ab_stack_size_n_aux_sections*/,
/* _flags at 344 / 368 */
# ifndef A_64
'_',
......@@ -2679,39 +2685,49 @@ data [] =
int_to_2_chars (0)/*flags_type*/,
(char) 2/*flags_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*flags_n_aux_sections*/,
/* _initial_heap_size at 362 / 386 */
int_to_4_chars (0), int_to_4_chars (28)/*initial_heap_size_offset*/,
int_to_4_chars (0),
# ifdef A_64
int_to_4_chars (28)/*initial_heap_size_offset*/,
int_to_4_chars (24)/*initial_heap_size_value*/,
# else
int_to_4_chars (30)/*initial_heap_size_offset*/,
int_to_4_chars (12)/*initial_heap_size_value*/,
# endif
int_to_2_chars (2)/*initial_heap_size_section_n*/,
int_to_2_chars (0)/*initial_heap_size_type*/,
(char) 2/*initial_heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*initial_heap_size_n_aux_sections*/,
/* _heap_size_multiple at 378 / 402 */
int_to_4_chars (0), int_to_4_chars (46)/*heap_size_multiple_offset*/,
int_to_4_chars (0),
# ifdef A_64
int_to_4_chars (46)/*heap_size_multiple_offset*/,
int_to_4_chars (32)/*heap_size_multiple_value*/,
# else
int_to_4_chars (49)/*heap_size_multiple_offset*/,
int_to_4_chars (16)/*heap_size_multiple_value*/,
# endif
int_to_2_chars (2)/*heap_size_multiple_section_n*/,
int_to_2_chars (0)/*heap_size_multiple_type*/,
(char) 2/*heap_size_multiple_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*heap_size_multiple_n_aux_sections*/,
/* _min_write_heap_size at 396 / 420 */
int_to_4_chars (0), int_to_4_chars(65)/*min_write_heap_size_offset*/,
int_to_4_chars (0),
# ifdef A_64
int_to_4_chars(65)/*min_write_heap_size_offset*/,
int_to_4_chars (40)/*min_write_heap_size_value*/,
# else
int_to_4_chars(69)/*min_write_heap_size_offset*/,
int_to_4_chars (20)/*min_write_heap_size_value*/,
# endif
int_to_2_chars (2)/*min_write_heap_size_section_n*/,
int_to_2_chars (0)/*min_write_heap_size_type*/,
(char) 2/*min_write_heap_size_class(IMAGE_SYM_CLASS_EXTERNAL)*/,
(char) 0/*min_write_heap_size_n_aux_sections*/,
/* string table at 414 / 438 */
# ifdef A_64
int_to_4_chars (81/*size string_table*/ + 4),
......@@ -3369,8 +3385,6 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
char o_file_name[PATH_NAME_STRING_SIZE],system_file_name[PATH_NAME_STRING_SIZE];
char *argv[1024],**arg;
struct library_list *library;
struct export_list *export;
struct export_file_list *export_file;
#if defined (OPTIMISE_LINK) || (defined (_WINDOWS_) && defined (USE_CLEANLINKER))
# ifdef _WINDOWS_
char quoted_linker_file_name_[PATH_NAME_STRING_SIZE];
......@@ -3395,7 +3409,7 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
#if defined (_WINDOWS_) && defined (USE_WLINK)
char w_crt0_file_name[PATH_NAME_STRING_SIZE];
#endif
#if defined (_WINDOWS_)
#if defined (_WINDOWS_) && (defined (USE_WLINK) || defined (OMF))
char stack_option[32];
#endif
#if defined (USE_CLEANLINKER)
......@@ -3529,6 +3543,10 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
*arg++=library->library_file_name;
}
{
struct export_list *export;
struct export_file_list *export_file;
for_l (export,first_export,export_next){
*arg++="-e";
*arg++=export->export_name;
......@@ -3538,6 +3556,8 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
*arg++="-E";
*arg++=export_file->export_file_name;
}
}
*arg=NULL;
......@@ -3884,6 +3904,7 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
PROCESS_INFORMATION pi;
HANDLE linkerrs;
char buffer[32767];
char *c_p;
char *cmd=buffer;
sa.nLength=sizeof (SECURITY_ATTRIBUTES);
......@@ -3903,11 +3924,13 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
si.hStdError=linkerrs;
*cmd++='"';
for (char *c=linker_file_name_; *c; c++)
*cmd++=*c;
for (c_p=linker_file_name_; *c_p; c_p++)
*cmd++=*c_p;
*cmd++='"';
for (arg=argv+1; *arg; arg++){
if (cmd+3+strlen(arg) > &buffer[32766]){
for (arg=argv+1; *arg; arg++){
c_p=*arg;
if (cmd+3+strlen(c_p) > &buffer[32766]){
fprintf (stderr,"Linker command line requires more than 32767 characters (use cpm instead)\n");
exit (1);
}
......@@ -3916,8 +3939,8 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
#ifndef QUOTE_SPAWN_ARGUMENTS
*cmd++='"';
#endif
for (char *c=*arg; *c; c++)
*cmd++=*c;
while (*c_p)
*cmd++=*c_p++;
#ifndef QUOTE_SPAWN_ARGUMENTS
*cmd++='"';
#endif
......@@ -4322,48 +4345,53 @@ extern int ccommand(char ***);
void init_directories_from_environment()
{
/* If the CLEAN_HOME environment variable is set, it is used to initialize the default directories */
char* clean_home = getenv("CLEAN_HOME");
if(clean_home != NULL) {
#ifdef _WINDOWS_
char* clean_home;
if (! (clean_lib_directory[0]=='.' && clean_lib_directory[1]=='\0' &&
clean_directory_list[0]=='.' && clean_directory_list[1]=='\0' &&
clean_include_library_directory[0]=='.' && clean_include_library_directory[1]=='\0'))
return;
#if defined (LINUX) || defined (_WINDOWS_)
/* If the CLEAN_HOME environment variable is set, it is used to initialize the default directories */
clean_home = getenv ("CLEAN_HOME");
if (clean_home==NULL)
return;
if (clean_lib_directory[0]=='.' && clean_lib_directory[1]=='\0'){
/* CLEANLIB */
strncpy(clean_lib_directory, clean_home, sizeof(clean_lib_directory));
# ifdef A_64
strncat(clean_lib_directory,"\\Tools\\Clean System 64",sizeof(clean_lib_directory) - strlen(clean_lib_directory));
# else
strncat(clean_lib_directory,"\\Tools\\Clean System",sizeof(clean_lib_directory) - strlen(clean_lib_directory));
# endif
/* CLEANPATH */
strncpy(clean_directory_list, clean_home, sizeof(clean_directory_list));
strncat(clean_directory_list,"\\Libraries\\StdEnv",sizeof(clean_directory_list) - strlen(clean_directory_list));
/* CLEANILIB */
strncpy(clean_include_library_directory, clean_home, sizeof(clean_include_library_directory));
strncat(clean_include_library_directory,"\\Libraries",sizeof(clean_include_library_directory) - strlen(clean_include_library_directory));
#else
# if defined (LINUX)
if (clean_lib_directory[0]=='.' && clean_lib_directory[1]=='\0'){
# endif
strncpy(clean_lib_directory, clean_home, sizeof(_clean_lib_directory) - 17);
strncat(clean_lib_directory,"/lib/exe",sizeof(_clean_lib_directory) - strlen(_clean_lib_directory) - 17);
# if defined (LINUX)
}
if (clean_directory_list[0]=='.' && clean_directory_list[1]=='\0'){
# ifdef _WINDOWS_
# ifdef A_64
strncat(clean_lib_directory,"\\Tools\\Clean System 64",sizeof(_clean_lib_directory) - 17 - strlen(clean_lib_directory));
# else
strncat(clean_lib_directory,"\\Tools\\Clean System",sizeof(_clean_lib_directory) - 17 - strlen(clean_lib_directory));
# endif
# else
strncat(clean_lib_directory,"/lib/exe",sizeof(_clean_lib_directory) - 17 - strlen(clean_lib_directory));
# endif
}
if (clean_directory_list[0]=='.' && clean_directory_list[1]=='\0'){
/* CLEANPATH */
strncpy(clean_directory_list, clean_home, sizeof(_clean_directory_list) - 17);
strncat(clean_directory_list,"/lib/StdEnv",sizeof(_clean_directory_list) - strlen(_clean_directory_list) - 17);
# if defined (LINUX)
}
if (clean_include_library_directory[0]=='.' && clean_include_library_directory[1]=='\0'){
# ifdef _WINDOWS_
strncat(clean_directory_list,"\\Libraries\\StdEnv",sizeof(_clean_directory_list) - 17 - strlen(clean_directory_list));
# else
strncat(clean_directory_list,"/lib/StdEnv",sizeof(_clean_directory_list) - 17 - strlen(clean_directory_list) - 17);
# endif
}
if (clean_include_library_directory[0]=='.' && clean_include_library_directory[1]=='\0'){
/* CLEANILIB */
strncpy(clean_include_library_directory, clean_home, sizeof(_clean_include_library_directory) - 17);
strncat(clean_include_library_directory,"/lib",sizeof(_clean_include_library_directory) - strlen(_clean_include_library_directory) - 17);
# if defined (LINUX)
}
# ifdef _WINDOWS_
strncat(clean_include_library_directory,"\\Libraries",sizeof(_clean_include_library_directory) - 17 - strlen(clean_include_library_directory));
# else
strncat(clean_include_library_directory,"/lib",sizeof(_clean_include_library_directory) - 17 - strlen(clean_include_library_directory));
# endif
#endif
}
#endif
}
#if defined (__MWERKS__)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment