Menu ▾ ▴

#4275 PIC16: fixing the address of a static variable generates duplicate symbols

pending-fixed
None
PIC16
5
2 days ago
2 days ago
No
static __data volatile unsigned char  __at(0x0200) volatileBits;

generates a dusplicate symbol:

udata_test_0    udata
_volatileBits   res     1


ustat_test_00   udata   0X0200
_volatileBits   res     1

which fails to assemble:

test.asm:21:Error[116]   Address label duplicated or different in second pass: "_volatileBits"
test.asm:21:Error[115]   Duplicate label or redefining symbol that cannot be redefined: "_volatileBits"

Discussion

  • Gabriele Gorla

    Gabriele Gorla - 2 days ago

    This issue is the root cause for the PIC16 bitfields-* regression failures where vartype is 5 or 6.

     
    • zeynelsagcan

      zeynelsagcan - 2 days ago

      Hi Gabriele,

      I reproduced the duplicate-symbol issue reported in #4275 using the official SVN r17255 sources.

      The root cause is in pic16emitRegularMap()` insrc/pic16/glue.c`.

      Static variables with absolute addresses are incorrectly added to pic16_rel_udata before being handled by the absolute-address allocation logic. This results in duplicate assembler symbol definitions.

      The attached patch adds a single condition:

      && !SPEC_ABSA(sym->etype)

      This prevents absolute-addressed static variables from entering the regular UDATA allocation path.

      Validation results (SVN r17255, PIC16):

      • Original duplicate-symbol reproducer: PASS (SDCC and GPASM).
      • Normal static variable allocation: PASS.
      • Absolute-addressed static variable allocation: PASS.
      • Absolute-addressed global variable allocation: PASS.
      • bitfields-checks, varType=5, struct=0/1: 2/2 PASS.
      • bitfields-checks, varType=6, struct=0/1: 2/2 PASS.
      • Absolute addresses verified: 0x0200 and 0x0204.
      • Patch reverse dry-run: PASS.

      All four bitfield variants compiled successfully with SDCC and assembled successfully with GPUTILS r1333.

      The patch modifies only src/pic16/glue.c.

      Runtime regression tests have not yet been performed.

      Attached: 4275_pic16_absolute_static.patch

      Best regards

       
  • Gabriele Gorla

    Gabriele Gorla - 2 days ago

    Thanks for the patch!

    fixed in [r17287]

     

    Related

    Commit: [r17287]

  • Gabriele Gorla

    Gabriele Gorla - 2 days ago
    • status: open --> pending-fixed
    • assigned_to: Gabriele Gorla
     

Log in to post a comment.