Update stable ABI script for MacOS and update list of exported symbols (GH-23783)

diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py
index b3a46f9..47547a9 100755
--- a/Tools/scripts/stable_abi.py
+++ b/Tools/scripts/stable_abi.py
@@ -31,6 +31,7 @@
     "ucnhash.h",
 }
 
+MACOS = (sys.platform == "darwin")
 
 def get_exported_symbols(library, dynamic=False):
     # Only look at dynamic symbols
@@ -57,7 +58,10 @@ def get_exported_symbols(library, dynamic=False):
             continue
 
         symbol = parts[-1]
-        yield symbol
+        if MACOS and symbol.startswith("_"):
+            yield symbol[1:]
+        else:
+            yield symbol
 
 
 def check_library(stable_abi_file, library, abi_funcs, dynamic=False):