Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
From: CRISTIAN ANDRES VARGAS GONZALEZ <vargascristian@americana.edu.co>
To: kernelnewbies@kernelnewbies.org
Subject: Are there global constructors in the Linux kernel?
Date: Tue, 8 Oct 2019 22:44:26 -0500
Message-ID: <CABfRCzhQkSgZaMX8PrZ2a0qSd=ezG3uxv8EC5TO21K0r9gv_jA@mail.gmail.com> (raw)

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

Good day

 I have been doing a little kernel following some repositories of GitHub,
videos and wikis, and I have found a topic that leaves me with doubts, the
theme is the global constructors.

Suppose I write a program in c, for the user space, for my code to run I
must have the main function
int main() { /*Code*/}

The gcc compiler searches for this function to run my program, but before
that happens, I can use the global constructors and write a code that runs
before the main function, but in the case of writing a kernel, why do I
need to run lines of code before the kernel is executed ?, I understand
that when writing a kernel there is no main function and that it is
disabled to indicate it to the compiler. In the Linux kernel are there
global constructors? If so, what things are executed before starting the
kernel?
att: cristian vargas.

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

<div dir="ltr"><br class="gmail-Apple-interchange-newline"><span style="font-family:arial,sans-serif;white-space:pre-wrap;background-color:rgb(248,249,250)">Good day</span> <br><br> I have been doing a little kernel following some repositories of GitHub, videos and wikis, and I have found a topic that leaves me with doubts, the theme is the global constructors.<br><br>Suppose I write a program in c, for the user space, for my code to run I must have the main function<br>int main() { /*Code*/}<div><span style="background-color:rgb(248,249,250);font-family:inherit;white-space:pre-wrap"><br></span></div><div><span style="background-color:rgb(248,249,250);font-family:inherit;white-space:pre-wrap">The gcc compiler searches for this function to run my program, but before that happens, I can use the global constructors and write a code that runs before the main function, but in the case of writing a kernel, why do I need to run lines of code before the kernel is executed ?, I understand that when writing a kernel there is no main function and that it is disabled to indicate it to the compiler.

</span>In the Linux kernel are there global constructors? If so, what things are executed before starting the kernel?<br><span style="background-color:rgb(248,249,250);font-family:inherit;white-space:pre-wrap">
att: cristian vargas. </span></div></div>

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

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

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09  3:44 CRISTIAN ANDRES VARGAS GONZALEZ [this message]
2019-10-09  6:54 ` Giovanni Mascellani
2019-10-09  8:54 ` Konstantin Andreev

Reply instructions:

You may reply publically 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='CABfRCzhQkSgZaMX8PrZ2a0qSd=ezG3uxv8EC5TO21K0r9gv_jA@mail.gmail.com' \
    --to=vargascristian@americana.edu.co \
    --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

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox