Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 12, 2015 Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Can this be done in D? How easy is it? What about the runtime? https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/ Best regards, NVolcz |
January 12, 2015 Re: Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Posted in reply to NVolcz Attachments: | On Mon, 12 Jan 2015 05:59:35 +0000 NVolcz via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > Can this be done in D? yes. > How easy is it? it depends of your experience and readyness to live without phobos and GC. > What about the runtime? you may need to write one which will include only functions your program requires. p.s. i've not visited the link. |
January 12, 2015 Re: Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Posted in reply to NVolcz | On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote: > Can this be done in D? How easy is it? What about the runtime? > > https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/ > Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes. http://goo.gl/qWhpVX Mike |
January 12, 2015 Re: Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Monday, 12 January 2015 at 08:46:57 UTC, Mike wrote:
> On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
>> Can this be done in D? How easy is it? What about the runtime?
>>
>> https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
>>
>
> Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes.
>
> http://goo.gl/qWhpVX
>
> Mike
Just posted the link to HN.
--
Paulo
|
January 12, 2015 Re: Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On 12 January 2015 at 08:46, Mike via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
>>
>> Can this be done in D? How easy is it? What about the runtime?
>>
>>
>> https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
>>
>
> Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes.
>
> http://goo.gl/qWhpVX
>
> Mike
>
Without performing any linker magic.
root@f6e559d2d853:~# cat > small.d << EOF
import core.stdc.stdio;
import core.stdc.stdlib;
extern(C) void main()
{
printf("Hello!\n");
exit(0);
}
EOF
root@f6e559d2d853:~# gdc -frelease -Os -nophoboslib -fno-emit-moduleinfo -nostdlib --entry=main small.d -lc -o small
root@f6e559d2d853:~# wc -c small
2488 small
root@f6e559d2d853:~# ./small
Hello!
|
January 12, 2015 Re: Writing a small linux binary | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Monday, 12 January 2015 at 09:00:58 UTC, Iain Buclaw via Digitalmars-d wrote:
> On 12 January 2015 at 08:46, Mike via Digitalmars-d
> <digitalmars-d@puremagic.com> wrote:
>> On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
>>>
>>> Can this be done in D? How easy is it? What about the runtime?
>>>
>>>
>>> https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
>>>
>>
>> Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M
>> platform in D. And, if I only used the string "Hello!" like the rust
>> example, I believe it would be 47 bytes.
>>
>> http://goo.gl/qWhpVX
>>
>> Mike
>>
>
>
> Without performing any linker magic.
>
> root@f6e559d2d853:~# cat > small.d << EOF
> import core.stdc.stdio;
> import core.stdc.stdlib;
>
> extern(C) void main()
> {
> printf("Hello!\n");
> exit(0);
> }
> EOF
>
> root@f6e559d2d853:~# gdc -frelease -Os -nophoboslib
> -fno-emit-moduleinfo -nostdlib --entry=main small.d -lc -o small
>
> root@f6e559d2d853:~# wc -c small
> 2488 small
>
> root@f6e559d2d853:~# ./small
> Hello!
Would be considered linker magic to use _start(), write() and _exit() instead? :)
--
Paulo
|
Copyright © 1999-2021 by the D Language Foundation