| ... | @@ -2270,8 +2270,9 @@ fn setGlobalSymbolValue( | ... | @@ -2270,8 +2270,9 @@ fn setGlobalSymbolValue( |
| 2270 | } | 2270 | } |
| 2271 | | 2271 | |
| 2272 | // If this symbol was previously undefined, relocations targeting it may have been lowered to | 2272 | // If this symbol was previously undefined, relocations targeting it may have been lowered to |
| 2273 | // runtime relocations which we have now discovered we do not need, so delete those. | 2273 | // runtime relocations which we have now discovered we do not need, so delete those. This does |
| 2274 | if (elf.shndx.dynamic != .UNDEF) { | 2274 | // not apply if the symbol is preemptible, which we check with `classifySymbolValue`. |
| | 2275 | if (elf.shndx.dynamic != .UNDEF and elf.classifySymbolValue(.global(global_name)) != .dynamic) { |
| 2275 | Symbol.Id.global(global_name).deleteDynamicTargetRelocs(elf); | 2276 | Symbol.Id.global(global_name).deleteDynamicTargetRelocs(elf); |
| 2276 | } | 2277 | } |
| 2277 | | 2278 | |
| ... | @@ -6925,6 +6926,9 @@ fn nodeWantsDsoRelocation(elf: *Elf, node: MappedFile.Node.Index) enum { yes, ye | ... | @@ -6925,6 +6926,9 @@ fn nodeWantsDsoRelocation(elf: *Elf, node: MappedFile.Node.Index) enum { yes, ye |
| 6925 | fn maybeAddCopyRelocation(elf: *Elf, global_name: String(.strtab)) Error!bool { | 6926 | fn maybeAddCopyRelocation(elf: *Elf, global_name: String(.strtab)) Error!bool { |
| 6926 | assert(elf.shndx.dynamic != .UNDEF); | 6927 | assert(elf.shndx.dynamic != .UNDEF); |
| 6927 | | 6928 | |
| | 6929 | // Only dynamic executables may contain `R_*_COPY` relocations. |
| | 6930 | if (elf.base.comp.config.output_mode != .Exe) return false; |
| | 6931 | |
| 6928 | const gpa = elf.base.comp.gpa; | 6932 | const gpa = elf.base.comp.gpa; |
| 6929 | | 6933 | |
| 6930 | const global_ptr = elf.globals.strong_undef.getPtr(global_name) orelse | 6934 | const global_ptr = elf.globals.strong_undef.getPtr(global_name) orelse |
| ... | @@ -6932,10 +6936,6 @@ fn maybeAddCopyRelocation(elf: *Elf, global_name: String(.strtab)) Error!bool { | ... | @@ -6932,10 +6936,6 @@ fn maybeAddCopyRelocation(elf: *Elf, global_name: String(.strtab)) Error!bool { |
| 6932 | | 6936 | |
| 6933 | assert(global_ptr.dynsym_index != 0); | 6937 | assert(global_ptr.dynsym_index != 0); |
| 6934 | | 6938 | |
| 6935 | // Only dynamic executables may contain `R_*_COPY` relocations. | | |
| 6936 | if (elf.shndx.dynamic == .UNDEF) return false; | | |
| 6937 | if (elf.base.comp.config.output_mode != .Exe) return false; | | |
| 6938 | | | |
| 6939 | const dso_global = elf.dso_globals.get(global_name) orelse { | 6939 | const dso_global = elf.dso_globals.get(global_name) orelse { |
| 6940 | // We do not have a definition to provide the correct size for the symbol. If a definition | 6940 | // We do not have a definition to provide the correct size for the symbol. If a definition |
| 6941 | // is discovered in a later DSO, we may at that point be able to add a copy relocation. | 6941 | // is discovered in a later DSO, we may at that point be able to add a copy relocation. |