This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Code links incorrectly with symbol hiding

Toolchain: ARM Optimizing C/C++ Compiler v5.1.1

Hello,

I am getting a weird link when I introduce symbol hiding to my code. When I compile a partial out file, link it to an object, and run it, the code runs fine.  When I turn on --hide=* on the partial file (with everything else unchanged), link, and run it, it does not function.

Our code needs to be packaged as a partial out file and sent to a 3rd party supplier (who is also our competitor) for them to integrate a part of the code.  I have been able to turn on symbol hiding (with --hide/--unhide) to block off as much as possible.

Details to help troubleshoot:

1) The partial files have the same layout hidden or unhidden.  I was able to verify this with the map file (both have identical Section Allocation maps, the first difference in the map files are in the Global Symbols section).

2) The final links have the same layout.  (same verification as above)

3) The object it links against is the same for both runs.

4) I ran a compare between the final S37 files and there are 266 different sections.  I did disassemble the code, and this is the first difference I found.

S32500040060F64F60A0F2C0000EF8D0041C0E051EA8B2C7F02AE96846684621463AF0ACFF9705 (normal)
S32500040060F64F60A0F2C0000EF8D0041C0E051EA8B2C7F02AF96746684621463AF0ACFF97F6 (hide)

Corresponding Assembly from listing file
   13871 000006dc 0E05              LSRS      V2, A1, #24           ; [DPU_4_PIPE0] |2275|  ; [ORIG 16-BIT INS]
   13872 000006de 1EA8              SUBS      A1, V2, #2            ; [DPU_4_PIPE0] |2275|  ; [ORIG 16-BIT INS]
   13873 000006e0 B2C7              UXTB      V4, A1                ; [DPU_4_PIPE0] |2275|  ; [ORIG 16-BIT INS]
   13894 000006e2 F7FFFFFE!         BL        SuspendOSCpuInterrupts ; [DPU_4_PIPE1] |2282|  ; [KEEP 32-BIT INS]

To verify that they both branch to the same function, I added a --unhide=SuspendOSCpuInterrupts and read the map file.
0004a2a4   SuspendOSCpuInterrupts
0004a2a4   SuspendOSCpuInterrupts

5) I had to add --trampolines=off to help make this easier to diagnose (was 1243 difference sections).  If on, normal has 5 trampolines (14 calls), and hide has 2 trampolines (6 calls).

Any suggestions on a next step of investigation?  I'm stumped now.

Thanks!
Steven
Edit: Added point 5
  • Steven,

    I think be problem is that you hid the mapping symbols, which are needed for the linker to determine where ARM code, Thumb code, and data segments begin and end. In the working example the instruction is a BLX and in the broken example the instruction is a BL. 

    Can you try adding --unhide=$a --unhide=$t --unhide=$d after the --hide=* option?

  • This fixed it, I can see that they build identically the same S37 now.  As a bonus, it even does not have any extra IP symbols.

    Thanks!

    Steven