Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #4831 > unrolled thread

code and data

Started by"Bill Cunningham" <nospam@nspam.invalid>
First post2014-10-20 15:55 -0400
Last post2014-10-20 23:09 +0100
Articles 8 — 3 participants

Back to article view | Back to comp.programming


Contents

  code and data "Bill Cunningham" <nospam@nspam.invalid> - 2014-10-20 15:55 -0400
    Re: code and data Melzzzzz <mel@zzzzz.com> - 2014-10-20 22:25 +0200
      Re: code and data "Bill Cunningham" <nospam@nspam.invalid> - 2014-10-20 17:34 -0400
        Re: code and data Melzzzzz <mel@zzzzz.com> - 2014-10-21 00:11 +0200
          Re: code and data "Bill Cunningham" <nospam@nspam.invalid> - 2014-10-20 20:01 -0400
    Re: code and data Richard Heathfield <invalid@see.sig.invalid> - 2014-10-20 21:29 +0100
      Re: code and data "Bill Cunningham" <nospam@nspam.invalid> - 2014-10-20 17:38 -0400
        Re: code and data Richard Heathfield <invalid@see.sig.invalid> - 2014-10-20 23:09 +0100

#4831 — code and data

From"Bill Cunningham" <nospam@nspam.invalid>
Date2014-10-20 15:55 -0400
Subjectcode and data
Message-ID<m23paq$4ht$1@speranza.aioe.org>
    Now is a flat binary only data or does it contain any code? I know the 
sections are stripped away.

Bill

[toc] | [next] | [standalone]


#4832

FromMelzzzzz <mel@zzzzz.com>
Date2014-10-20 22:25 +0200
Message-ID<20141020222517.4d3ceaf8@maxa-pc>
In reply to#4831
On Mon, 20 Oct 2014 15:55:15 -0400
"Bill Cunningham" <nospam@nspam.invalid> wrote:

>     Now is a flat binary only data or does it contain any code? I
> know the sections are stripped away.
> 
> Bill
> 
> 

What you mean by that? You can load binary into RAM and execute 
it no problem on Linux and Windows.

-- 
Manjaro all the way!
http://manjaro.org/

[toc] | [prev] | [next] | [standalone]


#4834

From"Bill Cunningham" <nospam@nspam.invalid>
Date2014-10-20 17:34 -0400
Message-ID<m23v5n$jib$1@speranza.aioe.org>
In reply to#4832
"Melzzzzz" <mel@zzzzz.com> wrote in message 
news:20141020222517.4d3ceaf8@maxa-pc...
> On Mon, 20 Oct 2014 15:55:15 -0400
> "Bill Cunningham" <nospam@nspam.invalid> wrote:
>
>>     Now is a flat binary only data or does it contain any code? I
>> know the sections are stripped away.
>>
>> Bill
>>
>>
>
> What you mean by that? You can load binary into RAM and execute
> it no problem on Linux and Windows.

    Only if there is relaocatable data mapped by the linker or loader for 
execution. And the binary happens to have executable code. If you remove 
section (or segment) headers which would be meaningful code, You'll have 
something that linux's file command would call data because it's 
unidentifiable. Not all binaries are executable on their own. JPEGs have a 
header and are binaries but not executable.

    What exactly is left when something has been reduced to a "flat binary"? 
That is what I'm meaning. Linux certainly can't identify it I know that.

Bill

[toc] | [prev] | [next] | [standalone]


#4837

FromMelzzzzz <mel@zzzzz.com>
Date2014-10-21 00:11 +0200
Message-ID<20141021001137.6b93d8c5@maxa-pc>
In reply to#4834
On Mon, 20 Oct 2014 17:34:56 -0400
"Bill Cunningham" <nospam@nspam.invalid> wrote:

> 
> "Melzzzzz" <mel@zzzzz.com> wrote in message 
> news:20141020222517.4d3ceaf8@maxa-pc...
> > On Mon, 20 Oct 2014 15:55:15 -0400
> > "Bill Cunningham" <nospam@nspam.invalid> wrote:
> >
> >>     Now is a flat binary only data or does it contain any code? I
> >> know the sections are stripped away.
> >>
> >> Bill
> >>
> >>
> >
> > What you mean by that? You can load binary into RAM and execute
> > it no problem on Linux and Windows.
> 
>     Only if there is relaocatable data mapped by the linker or loader
> for execution.

Well, you can write relocatable code in assembler or compile with PIC...
I did it. Loaded file in memory, mprotect it and just casted to
pointer to function and ...;)

 And the binary happens to have executable code. If you
> remove section (or segment) headers which would be meaningful code,
> You'll have something that linux's file command would call data
> because it's unidentifiable. Not all binaries are executable on their
> own. JPEGs have a header and are binaries but not executable.

You can execute anything in memory. Question is if you would get
meaningful result ;)

> 
>     What exactly is left when something has been reduced to a "flat
> binary"? That is what I'm meaning. Linux certainly can't identify it
> I know that.

Flat binary can be loaded into memory and run no problem. It just need
to have position independent code.

> 
> Bill
> 
> 



-- 
Manjaro all the way!
http://manjaro.org/

[toc] | [prev] | [next] | [standalone]


#4840

From"Bill Cunningham" <nospam@nspam.invalid>
Date2014-10-20 20:01 -0400
Message-ID<m247od$6rv$1@speranza.aioe.org>
In reply to#4837
"Melzzzzz" <mel@zzzzz.com> wrote in message 
news:20141021001137.6b93d8c5@maxa-pc...
> On Mon, 20 Oct 2014 17:34:56 -0400
> "Bill Cunningham" <nospam@nspam.invalid> wrote:
>
>>
>> "Melzzzzz" <mel@zzzzz.com> wrote in message
>> news:20141020222517.4d3ceaf8@maxa-pc...
>> > On Mon, 20 Oct 2014 15:55:15 -0400
>> > "Bill Cunningham" <nospam@nspam.invalid> wrote:
>> >
>> >>     Now is a flat binary only data or does it contain any code? I
>> >> know the sections are stripped away.
>> >>
>> >> Bill
>> >>
>> >>
>> >
>> > What you mean by that? You can load binary into RAM and execute
>> > it no problem on Linux and Windows.
>>
>>     Only if there is relaocatable data mapped by the linker or loader
>> for execution.
>
> Well, you can write relocatable code in assembler or compile with PIC...
> I did it. Loaded file in memory, mprotect it and just casted to
> pointer to function and ...;)
>
> And the binary happens to have executable code. If you
>> remove section (or segment) headers which would be meaningful code,
>> You'll have something that linux's file command would call data
>> because it's unidentifiable. Not all binaries are executable on their
>> own. JPEGs have a header and are binaries but not executable.
>
> You can execute anything in memory. Question is if you would get
> meaningful result ;)
>
>>
>>     What exactly is left when something has been reduced to a "flat
>> binary"? That is what I'm meaning. Linux certainly can't identify it
>> I know that.
>
> Flat binary can be loaded into memory and run no problem. It just need
> to have position independent code.

    Sounds like gcc -fPIC libraries.

Hummm

Bill

[toc] | [prev] | [next] | [standalone]


#4833

FromRichard Heathfield <invalid@see.sig.invalid>
Date2014-10-20 21:29 +0100
Message-ID<zge1w.538878$NQ4.299324@fx26.am4>
In reply to#4831
Bill Cunningham wrote:

>     Now is a flat binary only data or does it contain any code? I know the
> sections are stripped away.

The distinction between code and data is arbitrary. A program that zips up 
executables treats code as data. An interpreter treats data as code.

Here's a binary (nybbled into hexadecimal for ease of reading).

74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD

Is that code or data?

The only meaningful answer is "yes".

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#4835

From"Bill Cunningham" <nospam@nspam.invalid>
Date2014-10-20 17:38 -0400
Message-ID<m23vcp$k34$1@speranza.aioe.org>
In reply to#4833
"Richard Heathfield" <invalid@see.sig.invalid> wrote in message 
news:zge1w.538878$NQ4.299324@fx26.am4...
> Bill Cunningham wrote:
>
>>     Now is a flat binary only data or does it contain any code? I know 
>> the
>> sections are stripped away.
>
> The distinction between code and data is arbitrary. A program that zips up
> executables treats code as data. An interpreter treats data as code.
>
> Here's a binary (nybbled into hexadecimal for ease of reading).
>
> 74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
> 57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
> 92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
> 66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD
>
> Is that code or data?
>
> The only meaningful answer is "yes".

What if your first two bytes, 74 4A was a format descriptor. Would that be 
considered "code"?

Bill


[toc] | [prev] | [next] | [standalone]


#4836

FromRichard Heathfield <invalid@see.sig.invalid>
Date2014-10-20 23:09 +0100
Message-ID<ZKf1w.579830$9I4.429405@fx35.am4>
In reply to#4835
Bill Cunningham wrote:

> 
> "Richard Heathfield" <invalid@see.sig.invalid> wrote in message
> news:zge1w.538878$NQ4.299324@fx26.am4...
>> Bill Cunningham wrote:
>>
>>>     Now is a flat binary only data or does it contain any code? I know
>>> the
>>> sections are stripped away.
>>
>> The distinction between code and data is arbitrary. A program that zips
>> up executables treats code as data. An interpreter treats data as code.
>>
>> Here's a binary (nybbled into hexadecimal for ease of reading).
>>
>> 74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
>> 57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
>> 92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
>> 66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD
>>
>> Is that code or data?
>>
>> The only meaningful answer is "yes".
> 
> What if your first two bytes, 74 4A was a format descriptor. Would that be
> considered "code"?

You seem to have missed my point. It's just bits. That's all. Bits have no 
intrinsic meaning. They mean what a programmer wants them to mean. If they 
are treated as code, they are code. They might be bad code or they might be 
good code, but they're code. If they are treated as data, they are data. 
They might be ill-formed data or well-formed data, but they're data. 
Dataness or codinosity is in the eye of the program that reads the bits.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web