From patchwork Mon Dec 21 16:47:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Usishchev X-Patchwork-Id: 559619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0164714029E for ; Tue, 22 Dec 2015 03:49:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=loj8rF4O; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=WVYTazfJHQowDPR9GdrXYYrLAaWdp mwFRu8prsky+bUu/bvor/UEGsK8tUiPOzyvMDnC4acHbuM4b6KpDv5mTmsK2Hw6v eXgAZJQu2BnWDC18FEcJ667w3+V7Opn66YUs6Rr875ZoMKgtH1xOUHrX6RCLRg9G DX3Prx0ZR+EdYM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=F3YBVinTM0uSL1+gQfXRKxqoiSg=; b=loj 8rF4OJwv793XahywtKs9JcRL9WztDDtYxf9Ou2du4wZfHyZnNjhmztMd1ExhUFM6 jzIEZqRa/J2YEaGbOD8eC2oAwnSMOD5wA/iGHq13UfnublvfdIgoLqXnd2kU3Opz hc6L2ms+AaxL3lKOrzZIzR6ZzEVEuoAcwDptHeMI= Received: (qmail 113452 invoked by alias); 21 Dec 2015 16:48:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113442 invoked by uid 89); 21 Dec 2015 16:48:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS, T_MANY_HDRS_LCASE autolearn=no version=3.3.2 spammy=unwind, H*r:Mon, HContent-type:mixed, globl X-HELO: mailout1.w1.samsung.com From: y.usishchev@samsung.com To: libc-alpha@sourceware.org Subject: [PATCH] ARM: Add .cantunwind to _start and _dl_start_user Date: Mon, 21 Dec 2015 19:47:14 +0300 Message-id: <87vb7r7nql.fsf@samsung.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-version: 1.0 Content-type: multipart/mixed; boundary="=-=-=" Hi all! This patch fixes the problem with wrong unwind info in rtld for arm. In last stage of linking ld.so we get (from previous relocatable links) two sections: '.text' and '.text.unlikely'. They are merged to resulting '.text' section and '.text.unlikely' goes first. If we are built with '-funwind-tables' both these sections has some unwind info and in '.text' first unwind item is not aligned with start of section (we have '_start' and '_dl_start_user' there and they don't have unwind info). So when the two sections are merged we get a gap in unwind info. When libgcc unwinder reaches '_dl_start_user', it searches for unwind information and finds entry from previous section '.text.unlikely' (function 'oom' in my case). Unwinding continues with wrong info and it's result is unpredictable (can even cause segfault in unwinder). BR, Yury Usishchev ChangeLog 2015-12-21 Yury Usishchev * sysdeps/arm/dl-machine.h (_start): Add .cantunwind (_dl_start_user): Add .cantunwind From 94241f03333d93428866367d14b70e813824b681 Mon Sep 17 00:00:00 2001 From: Yury Usishchev Date: Mon, 21 Dec 2015 17:58:52 +0300 Subject: [PATCH] Add .cantunwind to _start and _dl_start_user --- sysdeps/arm/dl-machine.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 6fb20bd..5e50f4d 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -140,6 +140,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) .globl _dl_start_user\n\ .type _dl_start_user, %function\n\ _start:\n\ + .fnstart\n\ @ we are PIC code, so get global offset table\n\ ldr sl, .L_GET_GOT\n\ @ See if we were run as a command with the executable file\n\ @@ -149,7 +150,10 @@ _start:\n\ mov r0, sp\n\ bl _dl_start\n\ @ returns user entry point in r0\n\ + .cantunwind\n\ + .fnend\n\ _dl_start_user:\n\ + .fnstart\n\ adr r6, .L_GET_GOT\n\ add sl, sl, r6\n\ ldr r4, [sl, r4]\n\ @@ -206,6 +210,8 @@ _dl_start_user:\n\ ldr r3, .L_ARGV\n\ str r2, [sl, r3]\n\ b .L_done_fixup\n\ + .cantunwind\n\ + .fnend\n\ \n\ .L_GET_GOT:\n\ .word _GLOBAL_OFFSET_TABLE_ - .L_GET_GOT\n\ -- 2.6.4