Add -znodelete linker option
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run

This option is needed for openssl to create a correct library.
This commit is contained in:
herman ten brugge 2025-08-16 18:29:19 +02:00
parent 19fdef46f9
commit f8eb5f4ab8
3 changed files with 5 additions and 0 deletions

View File

@ -1457,6 +1457,8 @@ static int tcc_set_linker(TCCState *s, const char *optarg)
s->filetype |= AFF_WHOLE_ARCHIVE;
} else if (link_option(&o, "no-whole-archive")) {
s->filetype &= ~AFF_WHOLE_ARCHIVE;
} else if (link_option(&o, "znodelete")) {
s->znodelete = 1;
#ifdef TCC_TARGET_PE
} else if (link_option(&o, "large-address-aware")) {
s->pe_characteristics |= 0x20;

1
tcc.h
View File

@ -741,6 +741,7 @@ struct TCCState {
unsigned char static_link; /* if true, static linking is performed */
unsigned char rdynamic; /* if true, all symbols are exported */
unsigned char symbolic; /* if true, resolve symbols in the current module first */
unsigned char znodelete; /* Set DF_1_NODELETE in dynamic section */
unsigned char filetype; /* file type for compilation (NONE,C,ASM) */
unsigned char optimize; /* only to #define __OPTIMIZE__ */
unsigned char option_pthread; /* -pthread option */

View File

@ -2939,6 +2939,8 @@ static int elf_output_file(TCCState *s1, const char *filename)
put_dt(dynamic, DT_TEXTREL, 0);
if (file_type & TCC_OUTPUT_EXE)
dt_flags_1 = DF_1_NOW | DF_1_PIE;
if (s1->znodelete)
dt_flags_1 |= DF_1_NODELETE;
}
put_dt(dynamic, DT_FLAGS, DF_BIND_NOW);
put_dt(dynamic, DT_FLAGS_1, dt_flags_1);