I found this md5 implementation in assembly and tried to test it. So I compiled and got error. So then I tried to compile files separately without linking and it went well but linking thrown error again:
$ makemd5-test-fast-x86gcc-c-std=c99-O2md5-test.cgcc-c-O1md5-fast-x86.Sgcc-omd5-test-fast-x86md5-test.omd5-fast-x86.omd5-test.o:md5-test.c:(.text+0x4d): undefinedreferenceto `md5_compress'md5-test.o:md5-test.c:(.text+0xd5): undefinedreferenceto `md5_compress'md5-test.o:md5-test.c:(.text+0x13a): undefinedreferenceto `md5_compress'D:/.../mingw32-8.1.0/.../ld.exe: md5-test.o: badrelocaddress0x130insection `.rdata'ect and there is D:/.../mingw32-8.1.0/.../ld.exe: finallinkfailed: Invalidoperationcollect2.exe: error: ldreturned1exitstatusMakefile:45: recipefortarget'md5-test-fast-x86'failedmake: *** [md5-test-fast-x86] Error1
I testes it under linux and it works without any such errors
First I thought it was something wrong with ld.exe: md5-test.o: bad reloc address 0x130 in section '.rdata' but soon I realised it's undefined reference that matters. So I chceked obj and there is md5_compress method so I don't get why it won't link. Then I checked C vesion of the same routine and it linked, no problem. So again I checked and there is _md5_compress exported in it.
Now, I guess, compiler adds underscore to compiled function name/s but why it won't add it to assembled version? And how to add it so it links?
Last edit: oset jan 2020-05-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I took a look at it and there is no prefixed underscore in assembled object.
$ nm md5-test.o md5-fast-x86.o
md5-test.o:
00000000 b .bss
00000000 d .data
(...)00000000 t .text
U ___main
U _calloc
(...)00000000 T _main
U _md5_compress ; <- that is what is "expected" in main()00000000 T _md5_hash
U _memcmp
(...)
md5-fast-x86.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 T md5_compress ; <- that is what is provided in md5-fast-x86.o
You could try to add -fleading-underscore as option to gcc but despite the claim in documentation it doens't work, I tell you that.
You could add something to force adding leading underscore to name of the function in md5-fast-x86.S, like this:
well, you can build shared libraries exporting symbols without the
32-bit ABI's leading underscore ... see here for reference the ld
tool's option for more detail. Nevertheless the import-library for
such a shared object (DLL) will contain the leading underscores. You
will need to use a definition file to create it, or you can link
directly to the DLL ... if you have headers, which properly define the
export's calling-convetion.
I took a look at it and there is no prefixed underscore in assembled object.
$ nm md5-test.o md5-fast-x86.o
md5-test.o:
00000000 b .bss
00000000 d .data
(...)
00000000 t .text
U ___main
U _calloc
(...)
00000000 T _main
U _md5_compress ; <- that is what is "expected" in main()
00000000 T _md5_hash
U _memcmp
(...)
md5-fast-x86.o:
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 T md5_compress ; <- that is what is provided in md5-fast-x86.o
You could try to add -fleading-underscore as option to gcc but despite the claim in documentation it doens't work, I tell you that.
You could add something to force adding leading underscore to name of the function in md5-fast-x86.S, like this:
Hello.
I found this md5 implementation in assembly and tried to test it. So I compiled and got error. So then I tried to compile files separately without linking and it went well but linking thrown error again:
I testes it under linux and it works without any such errors
First I thought it was something wrong with
ld.exe: md5-test.o: bad reloc address 0x130 in section '.rdata'
but soon I realised it's undefined reference that matters. So I chceked obj and there ismd5_compress
method so I don't get why it won't link. Then I checked C vesion of the same routine and it linked, no problem. So again I checked and there is_md5_compress
exported in it.Now, I guess, compiler adds underscore to compiled function name/s but why it won't add it to assembled version? And how to add it so it links?
Last edit: oset jan 2020-05-24
I took a look at it and there is no prefixed underscore in assembled object.
You could try to add
-fleading-underscore
as option to gcc but despite the claim in documentation it doens't work, I tell you that.You could add something to force adding leading underscore to name of the function in
md5-fast-x86.S
, like this:Hope it solves the problem.
Hello,
well, you can build shared libraries exporting symbols without the
32-bit ABI's leading underscore ... see here for reference the ld
tool's option for more detail. Nevertheless the import-library for
such a shared object (DLL) will contain the leading underscores. You
will need to use a definition file to create it, or you can link
directly to the DLL ... if you have headers, which properly define the
export's calling-convetion.
Hope that helps
Kai
Am So., 24. Mai 2020 um 18:18 Uhr schrieb Sam Tansy
tansy@users.sourceforge.net:
Thanks for advice. I have tested it and it works. Not a perfect solution but works. Unluckily '-fleading-underscore' indeed doesn't work.
And when comes to dll, thank you as well but it's just 1.6k of code. It meant to be included.
Last edit: oset jan 2020-05-26