Title: [276501] branches/safari-611-branch/Source/WebKit
Revision
276501
Author
[email protected]
Date
2021-04-23 09:53:23 -0700 (Fri, 23 Apr 2021)

Log Message

Cherry-pick r276482. rdar://problem/77074513

    [Mac] CMBaseClass object pointers can become unaligned on x86
    https://bugs.webkit.org/show_bug.cgi?id=224950
    <rdar://77020922>

    Reviewed by Eric Carlson.

    CMBaseClass has a 4-byte version member before its 8-byte pointers on x86. Deal with this
    the same way we do with other pointer-bearing, static, CM-type objects: enforce a 4-byte
    packing, and prepend the struct with another 4-byte object in order to force the pointers
    into 8-byte alignment.

    * Shared/mac/MediaFormatReader/CoreMediaWrapped.h:
    (WebKit::CoreMediaWrapped<Wrapped>::vTable):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276482 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (276500 => 276501)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-04-23 16:31:30 UTC (rev 276500)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-04-23 16:53:23 UTC (rev 276501)
@@ -1,3 +1,40 @@
+2021-04-23  Russell Epstein  <[email protected]>
+
+        Cherry-pick r276482. rdar://problem/77074513
+
+    [Mac] CMBaseClass object pointers can become unaligned on x86
+    https://bugs.webkit.org/show_bug.cgi?id=224950
+    <rdar://77020922>
+    
+    Reviewed by Eric Carlson.
+    
+    CMBaseClass has a 4-byte version member before its 8-byte pointers on x86. Deal with this
+    the same way we do with other pointer-bearing, static, CM-type objects: enforce a 4-byte
+    packing, and prepend the struct with another 4-byte object in order to force the pointers
+    into 8-byte alignment.
+    
+    * Shared/mac/MediaFormatReader/CoreMediaWrapped.h:
+    (WebKit::CoreMediaWrapped<Wrapped>::vTable):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-04-22  Jer Noble  <[email protected]>
+
+            [Mac] CMBaseClass object pointers can become unaligned on x86
+            https://bugs.webkit.org/show_bug.cgi?id=224950
+            <rdar://77020922>
+
+            Reviewed by Eric Carlson.
+
+            CMBaseClass has a 4-byte version member before its 8-byte pointers on x86. Deal with this
+            the same way we do with other pointer-bearing, static, CM-type objects: enforce a 4-byte
+            packing, and prepend the struct with another 4-byte object in order to force the pointers
+            into 8-byte alignment.
+
+            * Shared/mac/MediaFormatReader/CoreMediaWrapped.h:
+            (WebKit::CoreMediaWrapped<Wrapped>::vTable):
+
 2021-04-21  Alan Coon  <[email protected]>
 
         Cherry-pick r275805. rdar://problem/76963040

Modified: branches/safari-611-branch/Source/WebKit/Shared/mac/MediaFormatReader/CoreMediaWrapped.h (276500 => 276501)


--- branches/safari-611-branch/Source/WebKit/Shared/mac/MediaFormatReader/CoreMediaWrapped.h	2021-04-23 16:31:30 UTC (rev 276500)
+++ branches/safari-611-branch/Source/WebKit/Shared/mac/MediaFormatReader/CoreMediaWrapped.h	2021-04-23 16:53:23 UTC (rev 276501)
@@ -142,12 +142,23 @@
 template<typename Wrapped>
 const typename CoreMediaWrapped<Wrapped>::WrapperVTable& CoreMediaWrapped<Wrapped>::vTable()
 {
-    static constexpr CMBaseClass baseClass = wrapperClass<sizeof(Wrapped)>();
-    static constexpr WrapperClass derivedClass = Wrapped::wrapperClass();
+    // CMBaseClass contains 64-bit pointers that aren't 8-byte aligned. To suppress the linker
+    // warning about this, we prepend 4 bytes of padding when building.
+#if CPU(X86_64)
+    constexpr size_t padSize = 4;
+#else
+    constexpr size_t padSize = 0;
+#endif
+
+#pragma pack(push, 4)
+    static constexpr struct { uint8_t pad[padSize]; CMBaseClass baseClass; } baseClass { { }, wrapperClass<sizeof(Wrapped)>() };
+    static constexpr struct { uint8_t pad[padSize]; WrapperClass derivedClass; } derivedClass { { }, Wrapped::wrapperClass() };
+#pragma pack(pop)
+
 IGNORE_WARNINGS_BEGIN("missing-field-initializers")
     static constexpr WrapperVTable vTable {
-        { nullptr, &baseClass },
-        &derivedClass,
+        { nullptr, &baseClass.baseClass },
+        &derivedClass.derivedClass,
     };
 IGNORE_WARNINGS_END
     return vTable;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to