History

tccelf: Do not load all referenced libraries when linking a library

Recursive loading of all references can break linking of libraries (Example: building of netbsd-curses) Thanks grischka, Michael and Herman for the comments. -- Regards ... Detlef

Detlef Riekenberg committed 3 years ago

Commit 32c4df11 parent 6b967b11 file · +12 −3Browse files

Unified · Split

tccelf.c+12−3
@@ -3554,9 +3554,9 @@ static void store_version(TCCState *s1, struct versym_info *v, char *dynstr) · 3553 unmodified lines
35543554 #endif
35553555 }
35563556
3557−/* load a DLL and all referenced DLLs. 'level = 0' means that the DLL
3558− is referenced by the user (so it should be added as DT_NEEDED in
3559− the generated ELF file) */
3557+/* load a library / DLL
3558+ 'level = 0' means that the DLL is referenced by the user
3559+ (so it should be added as DT_NEEDED in the generated ELF file) */
35603560 ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
35613561 {
35623562 ElfW(Ehdr) ehdr;
@@ -3649,6 +3649,14 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 86 unmodified lines
36493649 }
36503650 }
36513651
3652+ /* do not load all referenced libraries
3653+ (recursive loading can break linking of libraries) */
3654+ /* following DT_NEEDED is needed for the dynamic loader (libdl.so),
3655+ but it is no longer needed, when linking a library or a program.
3656+ When tcc output mode is OUTPUT_MEM,
3657+ tcc calls dlopen, which handles DT_NEEDED for us */
3658+
3659+#if 0
36523660 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++)
36533661 if (dt->d_tag == DT_RPATH)
36543662 tcc_add_library_path(s1, dynstr + dt->d_un.d_val);
@@ -3666,6 +3674,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 11 unmodified lines
36663674 }
36673675 }
36683676 }
3677+#endif
36693678
36703679 ret_success:
36713680 ret = 0;

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