Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E21DEC4361B for ; Fri, 18 Dec 2020 09:22:20 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D142823A7B for ; Fri, 18 Dec 2020 09:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D142823A7B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=etri.re.kr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1kqBxN-00009V-HM; Fri, 18 Dec 2020 04:21:49 -0500 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (Exim 4.94) (envelope-from ) id 1kqBxK-00008W-U2 for kernelnewbies@kernelnewbies.org; Fri, 18 Dec 2020 04:21:47 -0500 Received: from unknown (HELO send001-relay.gov-dooray.com) (211.180.235.152) by 129.254.9.16 with ESMTP; 18 Dec 2020 18:21:38 +0900 X-Original-SENDERIP: 211.180.235.152 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.106] (HELO smtp001-imp.gov-dooray.com) ([10.162.225.106]) by send001-relay.gov-dooray.com with SMTP id 49cd6bdc5fdc74a3; Fri, 18 Dec 2020 18:21:39 +0900 DKIM-Signature: a=rsa-sha256; b=OmZxewk6fP0vZ8BK30kvsICpzZcNt+EkkHx/CYEzGY5K/7SAwG5lxCKpELl8X2RPb1++KyrUC3 z5G430A2DLAJHHTfqLJ9TbiXucwNWexjfOpsZSxEyOlLcZHbqFAKvxvQnfTEeWT1Q33lQQmbCa0a U5rv/KTdgL40BlGMbhajexb9Zk96/X2V7asgr9A4SVh4KRL8pJfRp/+EM02k8In4MQm3ybHDO+fI OYQugxuUWXTKLpXVw+NTO6PNcyIlV/GkkRyKgybuWjTdgBe31Shtj2vDRRjc858N+OcgI4Op7GSN Yk6pIN6K8Myzd5C2PwymxYU3LqQhky6XUumdoCoQ==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=T8iHcDvy+oeLA6spGXiPsupjfFP1GvAofsh0AipzVXw=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp001-imp.gov-dooray.com with SMTP id b746e4a95fdc74a2; Fri, 18 Dec 2020 18:21:39 +0900 From: To: Subject: how does objcopy work? and how does the linux kernel process relocation with that stripped off image? Date: Fri, 18 Dec 2020 18:21:36 +0900 Message-ID: <074901d6d51f$2f408bb0$8dc1a310$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdbVHy7XthvDtPzdTeGF+NSvvHHTKg== Content-Language: ko X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1044822446257451135==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multipart message in MIME format. --===============1044822446257451135== Content-Type: multipart/alternative; boundary="----=_NextPart_000_074A_01D6D56A.9F28A8E0" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_074A_01D6D56A.9F28A8E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I saw in a linux build log this command (how to generate from 'vmlinux' to 'Image'), > /home/ckim/N1SDP/arm-reference-platforms/tools/gcc/gcc-linaro-6.2.1-2016.11- x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-objcopy > -O binary -R .note -R .note.gnu.build-id -R .comment -S vmlinux arch/arm64/boot/Image so the 'Image' file is generated from 'vmlinux' by objcopy command and about the -S option, objcopy help says '-S --strip-all Remove all symbol and relocation information' I checked I can run 'Image' file on the machine and it really boots linux to some point(I just tested it on qemu-system-aarch64, with -m virt option), arm support person says the 'Image' file is loaded at 0x40000000 in the 'virt' machine when I passed the 'Image' with -kernel option.(I guess the qemu knows where to load it..). My question is, I understand I can load the 'Image' file anywhere on the memory (because it's position independent code using only relative offsets for function calls and variable addresses probably,..), and at some point the kernel itself relocates the kernel image to somewhere else. (In arm64 linux, they don't use compressed kernel, so is it not relocated later in this case?). How does the kernel program ('Image') relocates the image and setup the MMU table when there is no symbol or relocation table? Can anyone correct my understanding if I'm wrong and explain to me how objcopy works and how kernel relocation is done in this case?(if it's done). (I know 'vmlinux' file is ELF file so the loader knows where to load it from where to start it, but this 'Image' files doesn't have any such information). ------=_NextPart_000_074A_01D6D56A.9F28A8E0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I saw in a linux build log this = command (how to generate from 'vmlinux' to 'Image'),  =

 

> = /home/ckim/N1SDP/arm-reference-platforms/tools/gcc/gcc-linaro-6.2.1-2016.= 11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-objcopy

> -O binary -R .note -R = .note.gnu.build-id -R .comment -S vmlinux = arch/arm64/boot/Image

 

so the 'Image' file is generated from 'vmlinux' by objcopy = command and about the -S option, objcopy help says =

    '-S = --strip-all          &n= bsp;        Remove all symbol and = relocation information'

 

I checked I can run 'Image' file on the machine and it = really boots linux to some point(I just tested it on = qemu-system-aarch64, with -m virt option), arm support person says the = 'Image' file is loaded at 0x40000000 in the 'virt' machine when I passed = the 'Image' with -kernel option.(I guess the qemu knows where to load = it..). 

 

My question is, I understand I can load the 'Image' file = anywhere on the memory (because it's position independent code using = only relative offsets for function calls and variable addresses = probably,..), and at some point the kernel itself relocates the kernel = image to somewhere else. (In arm64 linux, they don't use compressed = kernel, so is it not relocated later in this case?). How does the kernel = program ('Image') relocates the image and setup the MMU table when there = is no symbol or relocation table? 

Can anyone correct my understanding = if I'm wrong and explain to me how objcopy works and how kernel = relocation is done in this case?(if it's done).   =

(I know = 'vmlinux' file is ELF file so the loader knows where to load it from = where to start it, but this 'Image' files doesn't have any such = information).

------=_NextPart_000_074A_01D6D56A.9F28A8E0-- --===============1044822446257451135== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============1044822446257451135==--