Commit Graph

35 Commits

Author SHA1 Message Date
Alain Mosnier 6d500e221a
Update README.md
Added section about reference implementation.
2018-07-28 23:22:00 +02:00
Alain Mosnier 924fba5c17 Replaced some for loops by memset 2018-07-28 22:02:09 +02:00
Alain Mosnier 9583456b32 Implemented workaround for ld issue with large BSS
The large arrays are now allocated on heap instead of in BSS. This
actually feels like a pretty stupid linker limitation, and the
workaround leads to code that is less readable. But it only impacts
the test program.

The issue was reported with GCC 7.3.0 and compiling for 64-bit arch on
MSYS2's MinGW compiler. GCC 7.3.0 for 64-bit on Linux (my own machine
and Travis) seems perfectly OK with a large BSS segment (around 3 GB
is what the test program uses for test data).

Reported issue:

$ make
cc -Wall -Wextra -Wpedantic   -c -o test.o test.c
cc -Wall -Wextra -Wpedantic   -c -o sha-256.o sha-256.c
cc   test.o sha-256.o   -o test
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o: in function `__tmainCRTStartup':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:251:(.text+0x1cd): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_Sleep' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dkhchs01360.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:278:(.text+0x255): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_SetUnhandledExceptionFilter' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dkhchs01346.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:286:(.text+0x283): relocation truncated to fit: R_X86_64_PC32 against symbol `__mingw_winmain_hInstance' defined in COMMON section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:312:(.text+0x2f3): relocation truncated to fit: R_X86_64_PC32 against symbol `__mingw_winmain_lpCmdLine' defined in COMMON section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:238:(.text+0x475): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetStartupInfoA' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dkhchs00721.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-gccmain.o): in function `__main':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/gccmain.c:74:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/gccmain.c:76:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-charmax.o): in function `my_lconv_init':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/charmax.c:19:(.text+0x3): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp___lconv_init' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmsvcrt.a(dkxcbs00090.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-gs_support.o): in function `__security_init_cookie':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:62:(.text+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetSystemTimeAsFileTime' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dkhchs00746.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:70:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetCurrentProcessId' defined in .idata$5 section in C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libkernel32.a(dkhchs00536.o)
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:71:(.text+0x5b): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status
make: *** [<builtin>: test] Error 1```
2018-07-28 19:16:41 +02:00
Alain Mosnier 23b53726f3 Added explicit cast to correct printf() related bug 2018-07-28 16:53:38 +02:00
Alain Mosnier f03474231f Activated testing of long messages 2017-12-15 23:41:17 +01:00
Alain Mosnier a222d72880 Minor README change 2017-12-15 23:11:41 +01:00
Alain Mosnier 98a0bf165c Minor README change 2017-12-15 23:08:48 +01:00
Alain Mosnier 688b14926c Added Travis comment 2017-12-15 23:07:54 +01:00
Alain Mosnier d6b49c65bd Fixed minor warnings 2017-12-15 23:00:29 +01:00
Alain Mosnier a6c25e2cdf Included test in make 2017-12-15 22:53:19 +01:00
Alain Mosnier 538cfe97fa Travis icon again 2017-12-15 22:34:57 +01:00
Alain Mosnier 903e46163b Work on Travis icon 2017-12-15 22:33:50 +01:00
Alain Mosnier d87b78db4b Added Travis link 2017-12-15 22:31:02 +01:00
Alain Mosnier 19d1e8a568 Started adding Travis 2017-12-15 22:24:03 +01:00
Alain Mosnier 8f83e8dedf Minor README change 2017-12-15 21:54:31 +01:00
Alain Mosnier 369c47af63 Minor README change 2017-12-15 21:52:36 +01:00
Alain Mosnier b177afbe06 Improved formatting 2017-12-15 21:45:25 +01:00
Alain Mosnier 8fd2b04fed Improved formatting 2017-12-15 21:44:04 +01:00
Alain Mosnier 96988951cc Improved formatting 2017-12-15 21:40:56 +01:00
Alain Mosnier 37500f461f Formatting improvement 2017-12-15 21:37:39 +01:00
Alain Mosnier 6f35ae7007 Added extensive testing 2017-12-15 21:34:20 +01:00
Alain Mosnier cba84edcb5 Made changes according to review comments from StackExchange CODE REVIEW 2017-12-15 19:37:47 +01:00
Alain Mosnier d7214be727 Added comment about code review 2017-12-14 22:45:59 +01:00
Alain Mosnier da12ae4e94 Tests at compile time instead of runtime 2017-12-14 20:11:09 +01:00
Alain Mosnier b21a7b5529 Added comment 2017-12-13 12:03:01 +01:00
Alain Mosnier 85e93b4a79 Typo 2017-12-13 12:01:19 +01:00
Alain Mosnier ccc3d23b29 Added comment. 2017-12-13 12:00:03 +01:00
Alain Mosnier 047f309134 Added comment about testing 2017-12-13 11:29:58 +01:00
Alain Mosnier 5833df68d9 Removed temporary code 2017-12-13 11:27:39 +01:00
Alain Mosnier f3f5e1b453 Added some notes 2017-12-13 11:23:44 +01:00
Alain Mosnier 097f4b536d Typo 2017-12-13 11:18:17 +01:00
Alain Mosnier 73684be162 Corrected typo 2017-12-13 11:14:32 +01:00
Alain Mosnier 489f5e66b6 Completed the implementation, including testing, and fixed bugs 2017-12-13 11:12:47 +01:00
Alain Mosnier d676207600 Started a SHA-256 implementation. Buggy so far. 2017-12-13 00:52:28 +01:00
Alain Mosnier 3433d4ef5c
Initial commit 2017-12-12 20:48:09 +01:00