Discuss Scratch

GeonoTRON2000
Scratcher
100+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

I've successfully made a programs that dumps its executable data that is stored in memory to the STDOut. When I direct this output to a file, it works great, except I can't figure out how to link it with ELF. I get the following error:
/usr/lib/x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
Here's the linking command line I'm using:
ld -b elf64-x86-64 -o selfprinthex /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o -lc -b binary selfprint.hex -b elf64-x86-64 /usr/lib/x86_64-linux-gnu/crtn.o
Thanks in advance!

Last edited by GeonoTRON2000 (May 29, 2013 00:58:08)

TheMonsterOfTheDeep
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

What do you mean by “made a program?” If you're using e.g. C, then you can use gcc to link rather than calling ld directly.

Sadly, however, I can't help beyond that; I haven't actually learned much about the details of how to use ld. A cursory google search suggests that you probably don't have a ‘main’ method defined, which ld needs defined in order to make an executable.

my latest extension: 2d vector math
MegaApuTurkUltra
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

You need to tell the linker where the entry point of your executable data is. If you don't have anything besides your memory dump, you could try a base finder.

Last edited by MegaApuTurkUltra (Jan. 27, 2018 20:59:09)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
TheAspiringHacker
Scratcher
100+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

This topic is from 2013? Did @TheMosterOfTheDeep necropost or was a post deleted that bumped this topic back to the front page?

Long live Kyoto Animation!
cheeseeater
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

TheAspiringHacker wrote:

This topic is from 2013? Did @TheMosterOfTheDeep necropost or was a post deleted that bumped this topic back to the front page?
TheMonsterOfTheDeep didn't necropost. It was just more asinine spam that keeps finding its way on here.
Jonathan50
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

TheAspiringHacker wrote:

This topic is from 2013? Did @TheMosterOfTheDeep necropost or was a post deleted that bumped this topic back to the front page?
This topic was on the very last page, then somebody bumped it and it got deleted.

Not yet a Knight of the Mu Calculus.
MegaApuTurkUltra
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

aaa didn't see the date

Maybe the ST should close old topics that get bumped by spam when they delete the spam?

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
TheMonsterOfTheDeep
Scratcher
1000+ posts

[Ubuntu x86_64] Linking Binary Files! (HELP)

TheAspiringHacker wrote:

This topic is from 2013? Did @TheMosterOfTheDeep necropost or was a post deleted that bumped this topic back to the front page?
Ah shoot. Didn't notice the date.

Yup, it was spam.

my latest extension: 2d vector math

Powered by DjangoBB