Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.development > #9574

Re: Questions about the Implementation of the ELF format

From Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm>
Newsgroups alt.os.development
Subject Re: Questions about the Implementation of the ELF format
Date 2016-05-27 03:09 -0400
Organization Aioe.org NNTP Server
Message-ID <20160527030956.5383a466@_> (permalink)
References <06b38764-b3ee-4eed-9b82-f62c1d68b0ec@googlegroups.com> <ba3e35ec-d8f7-4d00-940b-e04c1ba1d581@googlegroups.com> <ni5b17$10pn$1@gioia.aioe.org> <d26c82e5-f9db-4247-80a7-97f5157d84e3@googlegroups.com>

Show all headers | View raw


On Thu, 26 May 2016 14:51:42 -0700 (PDT)
"Isaac D. Cohen" <8switchsoftware@gmail.com> wrote:

> So we can compile this independent code as follows:
> 
> gcc -c <filename.c>
> 
> But wait. That just created an ELF object file. Furthermore, we can
> only link with an assembly file that has also been assembled into an
> object file. We can't link with pure binary. So how can we create a
> pure binary kernel?

After compiling or assembling your code to object file, but prior to
linking, you may be able to use a linker line like below with the object
file.  This is for GNU ld:

ld --oformat binary -Ttext=0xORG -e start -o file.bin file.o

You should be able to put multiple objects on the ld line to be
linked.  I'm not sure if this will link together what you need.

(If you're not using GNU toolchain, that will be something different.
You'll need to specify which compiler or assembler or toolchain.)

"start" is the entry label.  0xORG is the hexadecimal start address or
offset the code is being compiled for.

That would require a "start" label in GAS assembly like this:

.global _start
_start:

For 64-bit Linux, GCC inserts a "cmain" label:

.globl cmain
cmain:


I'm sure there are some missing details there that you'll have to work
out by reading the manuals or or trial and error or help options or
searching the net.


Rod Pemberton

Back to alt.os.development | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-23 22:07 -0700
  Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-05-24 03:48 -0400
  Questions about the Implementation of the ELF format Peter Cheung <mcheung63@gmail.com> - 2016-05-24 01:10 -0700
  Re: Questions about the Implementation of the ELF format "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-05-24 01:18 -0700
  Re: Questions about the Implementation of the ELF format "Mike Gonta" <mikegonta@gmail.com> - 2016-05-24 10:34 -0400
  Re: Questions about the Implementation of the ELF format Herbert Kleebauer <klee@unibwm.de> - 2016-05-24 17:24 +0200
  Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-24 14:18 -0700
    Re: Questions about the Implementation of the ELF format "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-05-25 02:21 -0700
  Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-25 15:02 -0700
    Re: Questions about the Implementation of the ELF format "Mike Gonta" <mikegonta@gmail.com> - 2016-05-25 19:03 -0400
      Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-26 14:51 -0700
        Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-05-27 02:55 -0400
          Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-27 13:43 -0700
            Re: Questions about the Implementation of the ELF format "Mike Gonta" <mikegonta@gmail.com> - 2016-05-27 17:40 -0400
              Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-05-28 20:15 -0700
                Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-05-29 02:35 -0400
                Re: Questions about the Implementation of the ELF format "Isaac D. Cohen" <8switchsoftware@gmail.com> - 2016-06-15 13:51 -0700
        Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-05-27 03:09 -0400
        Re: Questions about the Implementation of the ELF format "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-05-27 00:10 -0700
        Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-06-02 16:25 -0400
      Re: Questions about the Implementation of the ELF format Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-05-27 02:38 -0400
        Re: Questions about the Implementation of the ELF format "Mike Gonta" <mikegonta@gmail.com> - 2016-05-27 04:11 -0400
    Re: Questions about the Implementation of the ELF format "Alexei A. Frounze" <alexfrunews@gmail.com> - 2016-05-25 22:18 -0700

csiph-web