kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: <ckim@etri.re.kr>
To: <kernelnewbies@kernelnewbies.org>
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	[thread overview]
Message-ID: <074901d6d51f$2f408bb0$8dc1a310$@etri.re.kr> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1672 bytes --]

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).


[-- Attachment #1.2: Type: text/html, Size: 4392 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

                 reply	other threads:[~2020-12-18  9:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='074901d6d51f$2f408bb0$8dc1a310$@etri.re.kr' \
    --to=ckim@etri.re.kr \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).