Location of startup prefix code?

When building a new (and empty) Uno project, the resulting executable always winds up with a bit of prefix code to clear SREG, set up the stack and initialize global variables prior to the jump to main():

Where is this code located in the Arduino IDE folder? More to the point, what's the easiest way to get rid of it?

I think, the easiest way to get rid of this code is to start programming in ASM.

Whole this code is by AVR C/C++. It is about how the variables, memories etc. are treated, it drives the behavior of MCU if something went wrong... In addition, this is convention used not only for AVR but across all other computer platforms. It is pretty universal. Of course, there are some ways how to get rid of unneeded parts but it is advanced programming.

Without this, it is you who have to treat and solve every single tiny thing. resources. If you really want this, you should start with studying MCU's documentation but you will find out soon that e.g. the SREG have to be cleared at some points of the program.

Budvar10:
Without this, it is you who have to treat and solve every single tiny thing. resources.

Thanks for the response Budvar10, but the desire to "solve every tiny thing" is actually the whole point behind my question (I'm currently experimenting with AVR subset implementations on FPGA). The screenshot above is actually from an embedded debugger in an AVR simulator I wrote years ago, so I'm fairly confident with the hardware side of things. I'm just trying to find out if there's a quick and easy way to use the IDE for code generation, and that prefix code is currently getting in my way.

Probably a dumb question, but do you still get it if you compile this sketch?:

int main() {
  return 0;
}

pert:
Probably a dumb question, but do you still get it if you compile this sketch?:

It strips the RAM initialization loop, but not the SREG and stack setup instructions.

OK, I figured. I don't know anything about assembly so I didn't know where that code was coming from. The Arduino core's default main() calls init() and I thought it might be coming from there.

https://www.nongnu.org/avr-libc/

The gcrt1.S is maybe what you are looking for.

@pert: The Arduino core adds another "ballast" to any program created in IDE. It is in the Wiring.

Budvar10:
The gcrt1.S is maybe what you are looking for.

That definitely looks like the right source file, now it's just a matter of figuring out where that is in the current Arduino package...v1.8.5 doesn't seem to have the same gcc folder structure that was present in earlier builds?

It's part of the compiler/libc package, so it's somewhere like .../hardware/tools/avr/avr/lib/avr5/crtatmega328p.o

Get rid of it by compiling and linking with avr-gcc from a CLI instead of the IDE, using the -nostartfiles switch. Note that this will get rid of your vectors as well; they're both part of the crt file.

For example, the optiboot bootloader suppresses these, and its compile line looks like:

avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L -Wl,--relax -nostartfiles -o optiboot_atmega328.elf optiboot.o

BTW, C code will break pretty fast if you leave out zeroing R1...

westfw:
Get rid of it by compiling and linking with avr-gcc from a CLI instead of the IDE, using the -nostartfiles switch.

Yeah, looks like that's what I'll have to do. I tried adding -nostartfiles to the IDE options, and I even linked manually to make sure I wasn't including core, but it doesn't seem to have worked.

Oh well, thanks anyway for help.

I tried adding -nostartfiles to the IDE options

Yeah, that's probably not a useful direction.
The IDE's main purpose is to add a bunch of stuff (hidden libraries, extra code, options, etc) to a simple user "sketch" to prevent them from having to know all the details.
Trying to use it for a stripped-down compile procedure is just ... not what it was designed to do.