Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11620

Changing the directory of the source files can cause the contents of the .rodata section to be ordered differently

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-11966
    • Hide
      ARMCLANG_4.0.0.LTS
      ARMCLANG_3.2.0.LTS
      Show
      ARMCLANG_4.0.0.LTS ARMCLANG_3.2.0.LTS
    • Hide
      ARMCLANG_3.2.3.LTS*
      ARMCLANG_4.0.2.LTS*
      Show
      ARMCLANG_3.2.3.LTS* ARMCLANG_4.0.2.LTS*
    • default
    • Hide
      Build with -fno-unique-string-section-names
      Show
      Build with -fno-unique-string-section-names

      When string constants are put into a .rodata input section, the name of the section includes a random number.  This random number is somehow related to the directory path that contains the file.  For .rodata input sections of the same length, this random number affects the order the input sections go into the .rodata output section.  Thus, changing the base directory of a project or package can cause the .rodata section to be put together differently.  This does not affect execution of the program.  But it is enough to fail compares of the final linked binary, built on different systems that put the project or package into different directories,  that consider the contents in the sections loaded to system memory.

      The attached test case is a cutdown of the real situation.  

      To get identical results to those shown here, it is likely the build has to be conducted on a Windows system, with the source files extracted into the directory C:\examples.

      Here are key lines from 1\f1.c ...

          char str[20];
      
          strcpy(str, "ABCDEFGH");
          do_work(str);
      

      The code in 2\f2.c is similar, but the string is "IJKLMNOP". Note these strings are the same length.

      The following commands build the code, show the details of the .rodata section in the map file, change the sub-directory names, then repeat.

      C:\examples>tiarmclang -I. main.c do_work.s 1\f1.c 2\f2.c -o main.out -Wl,-c,-m=main.map
      
      C:\examples>findstr rodata main.map
        000008c0    000008c0    00000012   00000012    r-- .rodata
      .rodata    0    000008c0    00000012
                        000008c0    00000009     f2-7058b1.o (.rodata.str1.162034530002772785751)
                        000008c9    00000009     f1-5bf928.o (.rodata.str1.57988215789492645211)
      
      C:\examples>rename 1 111
      
      C:\examples>rename 2 222
      
      C:\examples>tiarmclang -I. main.c do_work.s 111\f1.c 222\f2.c -o main.out -Wl,-c,-m=main.map
      
      C:\examples>findstr rodata main.map
        000008c0    000008c0    00000012   00000012    r-- .rodata
      .rodata    0    000008c0    00000012
                        000008c0    00000009     f1-64ffd0.o (.rodata.str1.110236740361973107141)
                        000008c9    00000009     f2-fabb12.o (.rodata.str1.168638788258376218751)
      

      Note how the .rodata output section has the input sections in a different order. 

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: