Menu

#308 Incorrect duplicate symbol error

None
closed-fixed
None
1
2022-02-19
2017-11-08
No

I get the following error when the PIC libraries are built as part of the SDCC build using latest gputils revision (r1312):

'/usr/local/bin/gplib' -c libc18f.a iscntrl.o isdigit.o isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o isxdigit.o delay100ktcy.o delay100tcy.o delay10ktcy.o delay10tcy.o delay1ktcy.o delay1mtcy.o fprintf.o printf.o printf_small.o printf_tiny.o putchar.o sprintf.o streams.o strmgpsim.o strmmssp.o strmputchar.o strmusart.o vfprintf.o vprintf.o vsprintf.o atof.o atoi.o atol.o calloc.o crc16.o free.o g_ftoa.o itoa.o ltoa.o malloc.o memfree.o memfreemax.o memmisc.o rand.o realloc.o x_ftoa.o memccpy.o memchr.o memchrpgm.o memchrram.o memcmp.o memcpy.o memcpypgm2ram.o memcpyram2ram.o memmove.o memrchr.o memset.o strcat.o strchr.o strcmp.o strcpy.o strcspn.o strlen.o strlwr.o strncat.o strncmp.o strncpy.o strpbrk.o strrchr.o strspn.o strstr.o strtok.o strupr.o cnvfrac.o cnvint.o cvtdec.o

error: Duplicate symbol "digits" defined in "g_ftoa.o" and "cvtdec.o".
error: Duplicate symbol "cvt_dec_word" defined in "g_ftoa.o" and "cvtdec.o".

For example, cvtdec.S defines "digits" and g_ftoa.S uses it as an "extern" but it doesn't define it again. So it looks like a gputils bug? After testing different gputils revisions, I think it happened at r1312.

Please let me know if you need more info.

For the record, found while working on the pic16 regression tests for SDCC (https://sourceforge.net/p/sdcc/mailman/message/36107467/).

Thanks,
Diego

Discussion

  • Molnár Károly

    Molnár Károly - 2017-11-10
    • assigned_to: Molnár Károly
     
  • Molnár Károly

    Molnár Károly - 2017-11-10

    Thanks for the bug reports. Later I will have time to deal with it.

    Károly

     
  • Molnár Károly

    Molnár Károly - 2017-11-13

    So it looks like a gputils bug?

    This clearly is. When I changed r1311-> r1312 I fixed a bug, and this fix caused this newer bug.

    Please let me know if you need more info.

    Rather I should need a partner in the project.

     
  • Anonymous

    Anonymous - 2018-08-29

    I got bitten by similar as well. It appears that the extern directive, if it is after udata or code, now defines the symbol. For manual assembler code not such a big issue - just moving all externs to the top of file helps - but still an inconvenience.

     
  • Tomas Zellerin

    Tomas Zellerin - 2018-08-29

    See attached minimal test case.gpasm -c test.asm; gplink -o test.hex test.o -c should fail with undefined symbol, but it compiles. When udata and extern are swapped, error is signalled correctly.

    _do_extern calls set_global that was changed in 1312. Attached one-line patch apparently fixes the immediate issue for me (sets section to UNDEFINED for extern symbols), but I know nothing about context of the call, so...

     
  • Tomas Zellerin

    Tomas Zellerin - 2018-09-06

    There also appears to be another case where you can get duplicated labels - when you do two externs for same symbol. Mpasm is happy with that. The code tries to handle that, but fails, as the symbol->Type is never set, so it cannot match. Test case and suggested one-line patch attached.

     
  • Hans-Bernhard Broeker

    And FWIW, note that the distributed gputils-ext/example/example2 fails, too:

    $ LANG=C make
    gpasm -p 16f873 -c -M mastri2c.asm && mv mastri2c.d .deps/mastri2c.d
    mastri2c.asm:80:Warning[215] Processor superseded by command line.
    gpasm -p 16f873 -c -M init.asm && mv init.d .deps/init.d
    gpasm -p 16f873 -c -M i2ccomm.asm && mv i2ccomm.d .deps/i2ccomm.d
    gplink --map -s 16f873.lkr -o example2.hex mastri2c.o init.o i2ccomm.o
    error: Duplicate symbol "init_ports" defined in "mastri2c.o" and "init.o".
    error: Duplicate symbol "init_timer1" defined in "mastri2c.o" and "init.o".
    error: Duplicate symbol "sflag_event" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "eflag_event" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "i2cState" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "read_count" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "write_count" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "write_ptr" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "read_ptr" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "temp_address" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "service_i2c" defined in "mastri2c.o" and "i2ccomm.o".
    error: Duplicate symbol "init_i2c" defined in "mastri2c.o" and "i2ccomm.o".
    error: Error while writing hex file.
    make: *** [Makefile:12: example2.hex] Error 1
    

    All of those are actually GLOBAL in one file, and EXTERNAL in the other that it complains about.

    And yes, the patch shown up there does fix this case.

     

    Last edit: Hans-Bernhard Broeker 2018-10-20
  • Anonymous

    Anonymous - 2021-06-04

    Has this been fixed? I've been running a locally patched version (using Tomas Zellerin's patch above) on Gentoo but recently tried building on a Fedora machine and got hit by this bug again.

     
  • Schelte Bron

    Schelte Bron - 2022-01-20

    It has not been fixed. The patches are still necessary with the current HEAD, r1319.

     
  • Robert Pearce

    Robert Pearce - 2022-02-16

    This appears to have been fixed in release v1.5.2

     
  • Molnár Károly

    Molnár Károly - 2022-02-19
    • status: open --> closed-fixed
     
  • Molnár Károly

    Molnár Károly - 2022-02-19

    I think it's fine now because of another fix.

    Károly

     

Anonymous
Anonymous

Add attachments
Cancel