PeterPawn / decoder

"secrets" decoding for FRITZ!OS devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possbly little bug in functions.h

claudiomush opened this issue · comments

Hello, to avoid a compilation error of: multiple definitions... please declare
extern void (*usageScreen)(void);
in functions.h
Regards

Please provide more details ... which compiler environment was used and which errors were shown?

Your suggestions is - if I see it right, what you mean - the opposite of this pull request: #21

Maybe it's compiler-dependent ... therefore I want to get more info. On the other hand it's possibly only a duplicate of #21 (because I haven't pushed some changes yet) - with a different solution.

I'd prefer to remove the (unneeded) declaration - please check, whether this would solve your problem (with your environment), too.

Thx

Hello,
I'm using Ubuntu Mate 21.4 with the following:
gcc --version
gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc
g++ --version
g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.

Without "extern" a make give me the following:

make -j6

make -C src
make[1]: Entering directory '/home/src/decoder/src'
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c errors.c -o errors.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c output.c -o output.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c base32.c -o base32.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c base64.c -o base64.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c hex.c -o hex.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c encryption.c -o encryption.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c exportfile.c -o exportfile.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c memory.c -o memory.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c functions.c -o functions.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crypto_nettle.c -o crypto_nettle.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c options.c -o options.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c environ.c -o environ.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c license.c -o license.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crc32.c -o crc32.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c help.c -o help.o
gcc -static -Wl,--gc-sections -L. -o decoder errors.o output.o base32.o base64.o hex.o encryption.o exportfile.o memory.o functions.o crypto_nettle.o options.o environ.o license.o crc32.o help.o decfile.o decexp.o deccb.o decompose.o decsngl.o pkpwd.o checksum.o userpw.o devpw.o pwfrdev.o b32dec.o b32enc.o b64dec.o b64enc.o hexdec.o hexenc.o decoder.o -lnettle -lc
/usr/bin/ld: output.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: base32.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: base64.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: hex.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: encryption.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: exportfile.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: memory.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: functions.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: crypto_nettle.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: options.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: environ.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: license.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
/usr/bin/ld: crc32.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here /usr/bin/ld: help.o:(.bss.usageScreen+0x0): multiple definition of usageScreen'; errors.o:(.bss.usageScreen+0x0): first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:746: decoder] Error 1
make[1]: Leaving directory '/home/src/decoder/src'
make: *** [Makefile:24: decoder] Error 2

With "extern" :
make
make -C src
make[1]: Entering directory '/home/src/decoder/src'
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c errors.c -o errors.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c output.c -o output.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c base32.c -o base32.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c base64.c -o base64.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c hex.c -o hex.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c encryption.c -o encryption.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c exportfile.c -o exportfile.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c memory.c -o memory.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c functions.c -o functions.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crypto_nettle.c -o crypto_nettle.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c options.c -o options.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c environ.c -o environ.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c license.c -o license.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crc32.c -o crc32.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c help.c -o help.o
gcc -static -Wl,--gc-sections -L. -o decoder errors.o output.o base32.o base64.o hex.o encryption.o exportfile.o memory.o functions.o crypto_nettle.o options.o environ.o license.o crc32.o help.o decfile.o decexp.o deccb.o decompose.o decsngl.o pkpwd.o checksum.o userpw.o devpw.o pwfrdev.o b32dec.o b32enc.o b64dec.o b64enc.o hexdec.o hexenc.o decoder.o -lnettle -lc
find . -name ".with_lib*" -exec rm '{}' ;
[ "n" = "y" ] && touch .with_libcrypto || touch .with_libnettle
make[1]: Leaving directory '/home/src/decoder/src'

I hope was useful, thankyou.

Without "extern" a make give me the following:

I see ... but what happens, if you remove this line completely from functions.h?

I'm getting no problems with this patch, too:

diff --git a/src/functions.h b/src/functions.h
index 6e19d9f..7faf912 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -29,8 +29,6 @@

 typedef struct commandEntry commandEntry_t;

-void (*usageScreen)(void);
-
 struct commandEntry {
    char * *        *names;
    int             (*ep)(int argc, char **argv, int argo, commandEntry_t * entry);
[...]
make[3]: Leaving directory '/home/GitHub/decoder/src/nettle/nettle-3.6'
make[2]: Leaving directory '/home/GitHub/decoder/src/nettle'
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crypto_nettle.c -o crypto_nettle.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c options.c -o options.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c environ.c -o environ.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c license.c -o license.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c crc32.c -o crc32.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c help.c -o help.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c decfile.c -o decfile.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c decexp.c -o decexp.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c deccb.c -o deccb.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c decompose.c -o decompose.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c decsngl.c -o decsngl.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c pkpwd.c -o pkpwd.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c checksum.c -o checksum.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c userpw.c -o userpw.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c devpw.c -o devpw.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c pwfrdev.c -o pwfrdev.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c b32dec.c -o b32dec.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c b32enc.c -o b32enc.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c b64dec.c -o b64dec.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c b64enc.c -o b64enc.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c hexdec.c -o hexdec.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c hexenc.c -o hexenc.o
gcc -I./include -DNETTLE -W -Wall -Wformat=2 -std=c99 -fvisibility=hidden -DSTATIC -static -O2 -ffunction-sections -fdata-sections -c decoder.c -o decoder.o
gcc -static -Wl,--gc-sections -L. -o decoder errors.o output.o base32.o base64.o hex.o encryption.o exportfile.o memory.o functions.o crypto_nettle.o options.o environ.o license.o crc32.o help.o decfile.o decexp.o deccb.o decompose.o decsngl.o pkpwd.o checksum.o userpw.o devpw.o pwfrdev.o b32dec.o b32enc.o b64dec.o b64enc.o hexdec.o hexenc.o decoder.o -lnettle
find . -name ".with_lib*" -exec rm '{}' \;
[ "n" = "y" ] && touch .with_libcrypto || touch .with_libnettle
make[1]: Leaving directory '/home/GitHub/decoder/src'

and this would be my preferred solution here. This function pointer definition is only a relict from the (very far) past - no reason to define or keep it. There's no other "reference" to usageScreen anymore in any other source file.

And this change is in my local repo already for a long, long time - I didn't publish it yet, because I wanted to change many more things in a fell sweep. But it looks like this takes too much time - so I've merged the proposed PR just a moment before.

This should solve your problem ... if not, don't hesitate to re-open this issue.

Regards