flat assembler
Message board for the users of flat assembler.

Index > Heap > GCC - Compile with custom format

Author
Thread Post new topic Reply to topic
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Hello, today i ask me question. Is it possible to compile C or C++ code with gcc and make custom output format, with custom header (not elf, pe header) ?
Post 21 Mar 2020, 11:50
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1489
Furs
This is more about the GNU linker than GCC, since that's what ends up creating the final output file. But no, I don't think so, although you could try to hack it with post-processing tools. (i.e. write your program that parses a PE file and spits out a different format, during the build process of your project).

Or well, it's open source so you can fork it and add support for your own format, I guess.
Post 21 Mar 2020, 13:08
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Okay. And if i would like to fork it for example, do you know what files i need to change for change format output, and keywords ? There are any way to add new language style to gcc ?
Post 21 Mar 2020, 15:34
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1489
Furs
Sorry, I don't know that. I only dabbled with gcc plugins. The linker (gnu ld) is part of binutils, a separate project (but gcc depends on it).
Post 22 Mar 2020, 15:06
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2936
Location: vpcmipstrm
bitRAKE
I know you asked about gcc, but clang is mostly compatible flag-wise. Here is an explanation and example:

https://stackoverflow.com/questions/43551708/link-a-toy-os-using-llvm-clang

I typically use "-ffreestanding" just to code in raw C without inbuilt MS layer, and I look at the assembly code generated with "-mllvm --x86-asm-syntax=intel -S" (sending commands to LLVM allows for a lot of fine-grained control).

Edit: I tried the above example and it's still producing an ELF object with the linker. Using "--oformat binary" with the linker appears to be the way. Works with GNU LD and llvm's lld.

_________________
¯\(°_o)/¯ unlicense.org
Post 22 Mar 2020, 18:56
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 357
Ali.Z

_________________
Asm For Wise Humans
Post 01 Apr 2020, 07:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.