Include inline functions from BCM in the shared build's hashed region

There was a typo in the input section pattern. Compare nm -n
libcrypto.so and the relative order of symbols with
BORINGSSL_bcm_text_{start,end} before and after this change.

In doing so, we actually need to merge the relocation sections,
otherwise the linker complains there are multiple relocation sections
for one section.

I suspect this didn't happen before because .text.unlikely.* didn't
exist. There don't seem to be any .rela.rodata sections, but include it
for completeness.

Change-Id: If14e26d35008326acf2e58cfc0c5035bd4581e20
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/96527
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/crypto/fipsmodule/fips_shared.lds b/crypto/fipsmodule/fips_shared.lds
index 4f9c0a1..cffbcd3 100644
--- a/crypto/fipsmodule/fips_shared.lds
+++ b/crypto/fipsmodule/fips_shared.lds
@@ -4,10 +4,9 @@
     PROVIDE_HIDDEN(BORINGSSL_bcm_text_start = .);
     *(.text)
     *(.text.unlikely.*)
-    /* These sections shouldn't exist. But C++ `inline` symbols seem to be
-     * placed in function sections on Android even with
-     * -fno-function-sections. */
-    *(text.*)
+    /* C++ `inline` symbols are normally placed in their own sections to be
+     * deduplicated. Undo this. */
+    *(.text.*)
     PROVIDE_HIDDEN(BORINGSSL_bcm_text_end = .);
   }
   .rodata : {
@@ -17,12 +16,36 @@
     PROVIDE_HIDDEN(BORINGSSL_bcm_rodata_end = .);
   }
 
+  /* When multiple sections are merged, their corresponding relocation sections
+   * need to be merged as well. Older architectures (e.g. 32-bit Arm) tend to
+   * use .rel and newer ones (e.g. 64-bit Arm) tend to use .rela. */
+  .rel.text : {
+    *(.rel.text)
+    *(.rel.text.unlikely.*)
+    *(.rel.text.*)
+  }
+  .rela.text : {
+    *(.rela.text)
+    *(.rela.text.unlikely.*)
+    *(.rela.text.*)
+  }
+  .rel.rodata : {
+    *(.rel.rodata)
+    *(.rel.rodata.*)
+  }
+  .rela.rodata : {
+    *(.rela.rodata)
+    *(.rela.rodata.*)
+  }
+
   /DISCARD/ : {
     /* These sections shouldn't exist. In order to catch any slip-ups, direct
      * the linker to discard them. */
+    *(.rel.dyn)
     *(.rela.dyn)
     *(.data)
     *(.rel.ro)
+    *(.rela.ro)
     *(*.data.*)
   }
 }