History

Fix linkage of named file in loader script.

Remove the previous logic to link a named file with a loader script by using tcc_add_dll instead. Hence, all files can be linked, not only files ending in .so/.def.

Thomas Preud'homme committed 14 years ago

Commit 83d57c01 parent 5f99fe21 file · +9 −44Browse files

Unified · Split

tccelf.c+9−44
@@ -2846,40 +2846,6 @@ static int ld_next(TCCState *s1, char *name, int name_size) · 2845 unmodified lines
28462846 return c;
28472847 }
28482848
2849−/*
2850− * Extract the library name from the file name
2851− * Return 0 if the file isn't a library
2852− *
2853− * /!\ No test on filename capacity, be careful
2854− */
2855−static int filename_to_libname(TCCState *s1, const char filename[], char libname[])
2856−{
2857− char *ext;
2858− int libprefix;
2859−
2860− /* already converted to library name */
2861− if (libname[0] != '\0')
2862− return 1;
2863− ext = tcc_fileextension(filename);
2864− if (*ext == '\0')
2865− return 0;
2866− libprefix = !strncmp(filename, "lib", 3);
2867− if (!s1->static_link) {
2868− if (libprefix && (!strcmp(ext, ".so"))) {
2869− size_t len = ext - filename - 3;
2870− pstrncpy(libname, filename + 3, len);
2871− return 1;
2872− }
2873− } else {
2874− if (libprefix && (!strcmp(ext, ".a"))) {
2875− size_t len = ext - filename - 3;
2876− pstrncpy(libname, filename + 3, len);
2877− return 1;
2878− }
2879− }
2880− return 0;
2881−}
2882−
28832849 /*
28842850 * Extract the file name from the library name
28852851 *
@@ -2894,15 +2860,13 @@ static void libname_to_filename(TCCState *s1, const char libname[], char filenam · 8 unmodified lines
28942860 }
28952861 }
28962862
2897−static int ld_add_file(TCCState *s1, const char filename[], char libname[])
2863+static int ld_add_file(TCCState *s1, const char filename[])
28982864 {
28992865 int ret;
29002866
29012867 ret = tcc_add_file_internal(s1, filename, 0);
2902− if (ret) {
2903− if (filename_to_libname(s1, filename, libname))
2904− ret = tcc_add_library(s1, libname);
2905− }
2868+ if (ret)
2869+ ret = tcc_add_dll(s1, filename, 0);
29062870 return ret;
29072871 }
29082872
@@ -2948,7 +2912,7 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 39 unmodified lines
29482912 tcc_error_noabort("filename expected");
29492913 ret = -1;
29502914 goto lib_parse_error;
2951− }
2915+ }
29522916 if (!strcmp(filename, "AS_NEEDED")) {
29532917 ret = ld_add_file_list(s1, cmd, 1);
29542918 if (ret)
@@ -2956,13 +2920,14 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 1 unmodified line
29562920 } else {
29572921 /* TODO: Implement AS_NEEDED support. Ignore it for now */
29582922 if (!as_needed) {
2959− ret = ld_add_file(s1, filename, libname);
2923+ ret = ld_add_file(s1, filename);
29602924 if (ret)
29612925 goto lib_parse_error;
29622926 if (group) {
29632927 /* Add the filename *and* the libname to avoid future conversions */
29642928 dynarray_add((void ***) &libs, &nblibs, tcc_strdup(filename));
2965− dynarray_add((void ***) &libs, &nblibs, tcc_strdup(libname));
2929+ if (libname[0] != '\0')
2930+ dynarray_add((void ***) &libs, &nblibs, tcc_strdup(libname));
29662931 }
29672932 }
29682933 }
@@ -2975,8 +2940,8 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 6 unmodified lines
29752940 while (new_undef_syms()) {
29762941 int i;
29772942
2978− for (i = 0; i < nblibs; i += 2)
2979− ld_add_file(s1, libs[i], libs[i+1]);
2943+ for (i = 0; i < nblibs; i ++)
2944+ ld_add_file(s1, libs[i]);
29802945 }
29812946 }
29822947 lib_parse_error:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t