From patchwork Fri Apr 18 09:12:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 613 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id E05FE360075 for ; Fri, 18 Apr 2014 02:12:21 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 7426112E001B; Fri, 18 Apr 2014 02:12:21 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com 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 homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id 3E1A612E0017 for ; Fri, 18 Apr 2014 02:12:21 -0700 (PDT) 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:content-type:content-transfer-encoding :subject:message-id:date:to:mime-version; q=dns; s=default; b=t3 4iz14IO72CU7lgfwgaofooS0tjDhWQFdjNgbv5N4aHJw3GgQ1ZrdtLSWDS2cKAmy QVc1kKUoYoo/AKn1VsVHTazqgHogimsxylALxwQecNm4Bxv0qQ1/HyZvX3sDdyNj GhMBgLun3IM3JPFkpbUUmriPdBkc58qOO53wG7J6M= 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:content-type:content-transfer-encoding :subject:message-id:date:to:mime-version; s=default; bh=7xqhRwSw CfB9WNGT35ZClJX27CU=; b=peViFBExfWPcaLEZUvHLqsiZI7ZYUmBWdkPm/GQX Z6yvDjjB1QnEeOlJraeC3QZ+XheUNF2LmISkkcQi4GrYGbeYZeH20ap+TLRMe44u QAhjjJXZaVSC1zcj98Szi1VshQ1cuGZ+91TTzHrDGnXX3a3RsSvkj1dpwF2M+qE4 RVY= Received: (qmail 7102 invoked by alias); 18 Apr 2014 09:12:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7091 invoked by uid 89); 18 Apr 2014 09:12:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 18 Apr 2014 09:12:17 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4DA732722BB1 for ; Fri, 18 Apr 2014 11:12:15 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pjggSjzZyz5W for ; Fri, 18 Apr 2014 11:12:15 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 331012722B13 for ; Fri, 18 Apr 2014 11:12:15 +0200 (CEST) From: Tristan Gingold Subject: [darwin]: simplify solib-darwin.c Message-Id: Date: Fri, 18 Apr 2014 11:12:17 +0200 To: " ml" Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, function bfd_mach_o_get_base_address (to extract load address) has recently by added in bfd/mach-o.c, so we can use it to simplify a little bit solib-darwin.c Tested on a simply example and committed on trunk. Tristan. gdb/ * solib-darwin.c (darwin_solib_create_inferior_hook): Simplify code by using bfd_mach_o_get_base_address. diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index a9989ea..03b51d5 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -524,26 +524,10 @@ darwin_solib_create_inferior_hook (int from_tty) load_addr = darwin_read_exec_load_addr (info); if (load_addr != 0 && symfile_objfile != NULL) { - CORE_ADDR vmaddr = 0; - struct mach_o_data_struct *md = bfd_mach_o_get_data (exec_bfd); - unsigned int i, num; + CORE_ADDR vmaddr; /* Find the base address of the executable. */ - for (i = 0; i < md->header.ncmds; i++) - { - struct bfd_mach_o_load_command *cmd = &md->commands[i]; - - if (cmd->type != BFD_MACH_O_LC_SEGMENT - && cmd->type != BFD_MACH_O_LC_SEGMENT_64) - continue; - if (cmd->command.segment.fileoff == 0 - && cmd->command.segment.vmaddr != 0 - && cmd->command.segment.filesize != 0) - { - vmaddr = cmd->command.segment.vmaddr; - break; - } - } + vmaddr = bfd_mach_o_get_base_address (exec_bfd); /* Relocate. */ if (vmaddr != load_addr)