DO NOT MERGE - x86: Switch get_pc_thunk to comdat

Switch the __x86.get_pc_thunk.bx functions from .gnu.linkonce to comdat
section groups. lld doesn't implement .gnu.linkonce and will instead
discard the input sections. It might produce a faulty binary that has
no get_pc_thunk function in it, which would crash.

Normally, these functions are generated by GCC and are present in many
object files compiled with PIC. Clang doesn't use them, and instead
initializes the PIC base register with a "call 1f; 1: pop %ebx" pair.

I also added cfi_startproc / cfi_endproc to be consistent with current
GCC output.

I marked this CL with do-not-merge because the code it touches has been
removed in the next release, so it won't merge. I reviewed the
automerger graph, and this do-not-merge CL:
 - will be applied to qt-qpr1-dev-plus-aosp (which needs the CL)
 - won't be applied to rvc-dev-plus-aosp (which doesn't need the CL)

https://android-build.googleplex.com/builds/automerger/graph/project/googleplex-android/platform/system/core

Bug: http://b/154376560
Bug: https://bugs.llvm.org/show_bug.cgi?id=45594
Test: VM boots
Change-Id: I681c4c46503aff65f32a22c9da15397a42b67183
This commit is contained in:
Ryan Prichard 2020-04-18 02:53:04 -07:00
parent ff08a51a72
commit 82a0841468
2 changed files with 6 additions and 2 deletions

View file

@ -105,14 +105,16 @@ name: \
/* We loaded the jump table and adjuested EDX. Go. */ \
jmp *%ebx
.section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
.section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
.globl __x86.get_pc_thunk.bx
.hidden __x86.get_pc_thunk.bx
ALIGN (4)
.type __x86.get_pc_thunk.bx,@function
__x86.get_pc_thunk.bx:
cfi_startproc
movl (%esp), %ebx
ret
cfi_endproc
#else
# define ENTRANCE
# define RETURN_END ret

View file

@ -105,14 +105,16 @@ name: \
/* We loaded the jump table and adjuested EDX. Go. */ \
jmp *%ebx
.section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
.section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
.globl __x86.get_pc_thunk.bx
.hidden __x86.get_pc_thunk.bx
ALIGN (4)
.type __x86.get_pc_thunk.bx,@function
__x86.get_pc_thunk.bx:
cfi_startproc
movl (%esp), %ebx
ret
cfi_endproc
#else
# define ENTRANCE
# define RETURN_END ret