arm: libgcc: provide implementations of __sync_synchronize
commit439779bacee869643c93a4710a29f89ad031ee4a
authorRichard Earnshaw <rearnsha@arm.com>
Mon, 20 Nov 2023 14:04:17 +0000 (20 14:04 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Fri, 24 Nov 2023 14:15:26 +0000 (24 14:15 +0000)
treeb9faa298fbbca9d01bee2c3b2322bc069e376040
parent1802f64e674eeef0c0d7e8f6ca2846145ec16315
arm: libgcc: provide implementations of __sync_synchronize

Prior to Armv6 there was no architected method to synchronize data
across processors.  Armv6 saw the first introduction of
multi-processor support, using a CP15 operation; but this was
deprecated in Armv7 and is not supported on m-profile devices of any
form.  Armv7 (and armv6-m) and later support data synchronization via
the DMB instruction.

This all leads to difficulties when linking programs as the user
generally needs to know which synchronization method is needed, but
there seems no easy way around this, when there are no OS-related
primitives available.

I've addressed this by adding multiple variants of __sync_synchronize
to libgcc, one for each of the above use cases.  I've named these
__sync_synchronize_none, __sync_synchronize_cp15dmb and
__sync_synchronize_dmb.  I've also added three specs files that can be
used to direct the linker to pick the appropriate implementation.
Using specs fragments for this is preferable to directing the user to
directly use --defsym as the latter has to be placed at the correct
position on the command line to be effective and the spec rule ensures
this automatically.

I've also added a default implementation of __sync_synchronize.  The
default implementation will use DMB if that is available in the target
ISA, or fall back to a nul-implementation if it isn't.  In the latter
case it will cause the linker (GNU LD) to emit a warning that
specifies how to pick a specific implementation.  I've chosen not to
permit this default to use the CP15 solution as that has been
deprecated.

libgcc:

* config.host (arm*-*-eabi* | arm*-*-rtems*):
Add arm/t-sync to the makefile rules.
* config/arm/lib1funcs.S (__sync_synchronize_none)
(__sync_synchronize_cp15dmb, __sync_synchronize_dmb)
(__sync_synchronize): New functions.
* config/arm/t-sync: New file.
* config/arm/sync-none.specs: Likewise.
* config/arm/sync-dmb.specs: Likewise.
* config/arm/sync-cp15dmb.specs: Likewise.
libgcc/config.host
libgcc/config/arm/lib1funcs.S
libgcc/config/arm/sync-cp15dmb.specs [new file with mode: 0644]
libgcc/config/arm/sync-dmb.specs [new file with mode: 0644]
libgcc/config/arm/sync-none.specs [new file with mode: 0644]
libgcc/config/arm/t-sync [new file with mode: 0644]