Closed Bug 723939 Opened 12 years ago Closed 12 years ago

Linker needs to align to 16k boundaries on armv6

Categories

(Core :: mozglue, defect)

ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: ted, Assigned: glandium)

References

Details

Attachments

(2 files, 3 obsolete files)

After some detective work by glandium, sewardj, and jbramley, we found out that the reason the linker is failing on my armv6 builds is because there's a 16k alignment requirement.
Component: General → mozglue
Product: Fennec Native → Core
QA Contact: general → mozglue
As mentioned on IRC, another part of the problem is that the static linker doesn't help either, and we want it to align segments at 16k boundaries (that is, we need (p_vaddr - p_offset) % 16384 == 0).
This can be done with -Wl,-z,max-page-size=0x4000 in LDFLAGS. I'm not completely sure which of configure.in or mozconfig this should live in.
I think we should automatically add that to LDFLAGS in configure if we're targeting Android-armv6.
armv6 or less, since armv5 code can run on armv6.
Depends on: 725284
Comment on attachment 595355 [details] [diff] [review]
When reserving memory for the loaded library, ensure correct alignment for future MAP_SHARED mappings

seems harmless
Attachment #595355 - Flags: review?(taras.mozilla) → review+
Mmmmm interestingly, this breaks the linker on desktop :-/
I'm not entirely sure why it was breaking desktop and not android, but there seems to be pretty bad side effects keeping the mapping MAP_SHARED. So once we get a base address that can hold the library and that will work with MAP_SHARED later, just remap it MAP_PRIVATE instead.
Attachment #597384 - Flags: review?(taras.mozilla)
Attachment #595355 - Attachment is obsolete: true
Attachment #597384 - Flags: review?(taras.mozilla) → review+
There were single quotes instead of double quotes in the previous patch
Attachment #597711 - Flags: review?(ted.mielczarek)
Attachment #597402 - Attachment is obsolete: true
Attachment #597402 - Flags: review?(ted.mielczarek)
This applies the flag to nspr, too.
Attachment #597872 - Flags: review?(ted.mielczarek)
Attachment #597711 - Attachment is obsolete: true
Attachment #597711 - Flags: review?(ted.mielczarek)
Comment on attachment 597872 [details] [diff] [review]
part 2 - Ensure 16k alignment of ELF segments when building for ARM < v7

Review of attachment 597872 [details] [diff] [review]:
-----------------------------------------------------------------

::: configure.in
@@ +4091,5 @@
> +dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
> +if test -n "$MOZ_LINKER"; then
> +  if test "$CPU_ARCH" = arm; then
> +    dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
> +    ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`

Kind of awkward, but I don't have a better suggestion.

@@ +4095,5 @@
> +    ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
> +    dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
> +    if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
> +      LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000"
> +      _SUBDIR_LDFLAGS="$LDFLAGS"

Do we really want to stick all of our LDFLAGS in SUBDIR_LDFLAGS, or just this one thing?
Attachment #597872 - Flags: review?(ted.mielczarek) → review+
https://hg.mozilla.org/mozilla-central/rev/8a9d1df1c762
https://hg.mozilla.org/mozilla-central/rev/a69b347c4d35
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: