[Info-vax] Linking problem with multiply defined symbols, how to resolve?
hb
end.of at inter.net
Fri Sep 30 15:33:15 EDT 2022
On 9/30/22 19:24, Simon Clubley wrote:
> On 2022-09-30, Johnny Billquist <bqt at softjar.se> wrote:
>>
>> Maybe I wasn't paying attention. I don't think I've seen a previous
>> suggested solution that applies to VMS. And the solution for Unix from
>> which this started is questionable how well it actually works (not
>> entirely clear *which* symbol would in the end be the one your
>> application would resolve to).
>>
>
> _IF_ I understand what is being asked for here (two different source code
> modules both defining the same global symbol name), then it doesn't matter
> in Unix provided both symbols are the same size, and of the same type, as
> the code in both modules will end up referencing the same memory area.
Did you actually try this? On Linux with gcc and binutils I get
/usr/bin/ld: two.o:(.bss+0x0): multiple definition of `same';
one.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
Two different source modules both defining the same global is not what
the OP is asking for, otherwise he could not link on all Unix systems.
On Unix, shared libraries and symbol pre-emption ensures that this works
for him as expected.
More information about the Info-vax
mailing list