Skip to content

Conversation

@apaillier-ledger
Copy link
Contributor

@apaillier-ledger apaillier-ledger commented Dec 4, 2025

Description

Was noticed and worked around in some apps like there.

Here is newlib's strcasecmp in various configurations :

  • Right now built with GCC (12.2.1) :
00000000 <strcasecmp>:
       0: b530          push    {r4, r5, lr}
       2: 4604          mov     r4, r0
       4: 4d0c          ldr     r5, [pc, #0x30]         @ 0x38 <strcasecmp+0x38>
       6: f814 3b01     ldrb    r3, [r4], #1
       a: 5cea          ldrb    r2, [r5, r3]
       c: f002 0203     and     r2, r2, #0x3
      10: 2a01          cmp     r2, #0x1
      12: f811 2b01     ldrb    r2, [r1], #1
      16: bf08          it      eq
      18: 3320          addeq   r3, #0x20
      1a: 5ca8          ldrb    r0, [r5, r2]
      1c: f000 0003     and     r0, r0, #0x3
      20: 2801          cmp     r0, #0x1
      22: d103          bne     0x2c <strcasecmp+0x2c>  @ imm = #0x6
      24: 3220          adds    r2, #0x20
      26: 1a98          subs    r0, r3, r2
      28: d0ed          beq     0x6 <strcasecmp+0x6>    @ imm = #-0x26
      2a: bd30          pop     {r4, r5, pc}
      2c: 1a98          subs    r0, r3, r2
      2e: d1fc          bne     0x2a <strcasecmp+0x2a>  @ imm = #-0x8
      30: 2a00          cmp     r2, #0x0
      32: d1e8          bne     0x6 <strcasecmp+0x6>    @ imm = #-0x30
      34: e7f9          b       0x2a <strcasecmp+0x2a>  @ imm = #-0xe
      36: bf00          nop
      38: 01 00 00 00   .word   0x00000001
  • Built with clang (19.1.7) :
00000000 <strcasecmp>:
       0: b5d0          push    {r4, r6, r7, lr}
       2: af02          add     r7, sp, #0x8
       4: f240 0200     movw    r2, #0x0
       8: f2c0 0200     movt    r2, #0x0
       c: f102 0c01     add.w   r12, r2, #0x1
      10: f810 4b01     ldrb    r4, [r0], #1
      14: f81c 2004     ldrb.w  r2, [r12, r4]
      18: f002 0e03     and     lr, r2, #0x3
      1c: f811 2b01     ldrb    r2, [r1], #1
      20: f1be 0f01     cmp.w   lr, #0x1
      24: f81c e002     ldrb.w  lr, [r12, r2]
      28: bf08          it      eq
      2a: 3420          addeq   r4, #0x20
      2c: f00e 0303     and     r3, lr, #0x3
      30: 2b01          cmp     r3, #0x1
      32: bf08          it      eq
      34: 3220          addeq   r2, #0x20
      36: 4294          cmp     r4, r2
      38: d101          bne     0x3e <strcasecmp+0x3e>  @ imm = #0x2
      3a: 2a00          cmp     r2, #0x0
      3c: d1e8          bne     0x10 <strcasecmp+0x10>  @ imm = #-0x30
      3e: 1aa0          subs    r0, r4, r2
      40: bdd0          pop     {r4, r6, r7, pc}
  • Built with clang (19.1.7) and the -fropi -frwpi flags :
00000000 <strcasecmp>:
       0: b5d0          push    {r4, r6, r7, lr}
       2: af02          add     r7, sp, #0x8
       4: f64f 72f4     movw    r2, #0xfff4
       8: f6cf 72f8     movt    r2, #0xfff8
       c: 447a          add     r2, pc
       e: f102 0c01     add.w   r12, r2, #0x1
      12: bf00          nop
      14: f810 4b01     ldrb    r4, [r0], #1
      18: f81c 2004     ldrb.w  r2, [r12, r4]
      1c: f002 0e03     and     lr, r2, #0x3
      20: f811 2b01     ldrb    r2, [r1], #1
      24: f1be 0f01     cmp.w   lr, #0x1
      28: f81c e002     ldrb.w  lr, [r12, r2]
      2c: bf08          it      eq
      2e: 3420          addeq   r4, #0x20
      30: f00e 0303     and     r3, lr, #0x3
      34: 2b01          cmp     r3, #0x1
      36: bf08          it      eq
      38: 3220          addeq   r2, #0x20
      3a: 4294          cmp     r4, r2
      3c: d101          bne     0x42 <strcasecmp+0x42>  @ imm = #0x2
      3e: 2a00          cmp     r2, #0x0
      40: d1e8          bne     0x14 <strcasecmp+0x14>  @ imm = #-0x30
      42: 1aa0          subs    r0, r4, r2
      44: bdd0          pop     {r4, r6, r7, pc}

As noted by the wise @0pendev here, LLVM 19 is required as newlib can't be built with clang 14 currently used with the app-builder docker containers, so we'll probably wait for their migration to Debian 13 that comes with it by default. 🚨
And also libgloss has issues being built by something other than GCC, so it has been disabled as well.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Tests
  • Documentation
  • Other (for changes that might not fit in any category)

Auto cherry-pick in API_LEVEL

[x] TARGET_API_LEVEL: API_LEVEL_25

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.60%. Comparing base (5508407) to head (ca1c27d).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1351   +/-   ##
=======================================
  Coverage   78.60%   78.60%           
=======================================
  Files          42       42           
  Lines        4571     4571           
  Branches      669      669           
=======================================
  Hits         3593     3593           
  Misses        928      928           
  Partials       50       50           
Flag Coverage Δ
unittests 78.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@iartemov-ledger
Copy link
Contributor

Cool @apaillier-ledger !
Do the both clang compilations (with and without -fropi -frwpi flags) resolve ldr r5, [pc, #0x30] @ 0x38 <strcasecmp+0x38> issue - i.e. an attempt to read an external global array ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants