home *** CD-ROM | disk | FTP | other *** search
- Path: vb.franken.de!volker
- From: volker@vb.franken.de (Volker Barthelmann)
- Subject: Re: 680X0 -> PPC translator?
- Newsgroups: comp.sys.amiga.programmer
- References: <3143E4EB.7303@sapiens.com> <volker.0fsu@vb.franken.de> <31499F8E.26A9@netvision.net.il> <volker.0fw1@vb.franken.de> <315800D7.1854@sapiens.com>
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- Message-ID: <volker.0g32@vb.franken.de>
- Date: 28 Mar 96 01:38:51 MET
- Organization: home
-
- Avi L. (avil@sapiens.com) wrote:
- : Volker Barthelmann wrote:
- : >
- : > Jack (avilev@netvision.net.il) wrote:
- : > :
- : > : oh is that so?! unless you get the address from an outside source, such as allocating it YOU
- : > : must produce it, right?! so you have to have it stored somewhere in the program. if you get it
- : >
- : > No. I can get it from system functions or calculate it. And both possibilities
- : > can depend on information that is only available at runtime.
- :
- : you're a little confused here, you're talking about run-time values while that isn't necessary
- : to know when and how a certain memory space is used. you use the pointers as parameters
- : replacing the actual run-time addresses. these pointers already exist within the program
- : and can therefore be analyzed for any changes made to them and how they're being used.
-
- Once an external function is called almost all information becomes useless,
- because You don't know what memory it changes.
-
- : if you perform careful analysis of the pointers, and that means following the changes made
- : to them by the program, you CAN know in which context they are being used and act
- : appropriatly. for example:
-
- Perhaps You can perform this analysis. An algorithm can't.
-
- : call _malloc ; let's say register a1 holds the returned address.
- : move a1,xyz(a7) ; store it in some variable, noting the current value of a7.
-
- Of course You can have a structure holding all Your variables. Now You pass
- the address of this structure to an external function that writes some
- values into it and You lost.
-
- : what i mean is, you use your own value of a7 with an initial value of 0 and follow the
- : changes made to it resetting it to 0 on assignments. that way you don't need the actual value
- : of a7 for knowning to which variable it refers to. now you know the address of the pointer to
- : the allocated block i just malloc()'ed so you can know how it's being used later, eg. code or data.
- : and bear in mind that all memory allocation routines call evantually AllocMem() function so you
-
- There are several memory allocating functions or other functions You can't
- know anything about.
-
- : have the instruction address of where exactly the memory region was allocated and so you can change
- : the size argument for the function if that memory area is later used for self-modifying code.
- : also you have to follow any loops which do writes to the area cuz these might be the sections
- : that copy code into that area and so you have to make the adjustments so that they loop
- : according to the translated code size.
-
- You would have to adjust EVERYTHING that is in any way dependant on the code
- size! How are You going to do this?
-
- : > : from some outside source, such as malloc(), then you don't have it obviously but that being said
- : > : doesn't imply it's impossible to figure out in which context the address is being used (ie code
- : >
- : > Easy??
- :
- : yes easy, cuz as i said you know where it was allocated and you can change the appropriate
- : argument.
-
- Er..have You ever really programmed anything with data flow analysis?
-
- : > And in many programs You won't find any call to e.g. AllocMem with this
- : > size at all, because the program uses its own memory-pool-routines.
- : > Etc. etc...
- :
- : but then again it must have allocated the master pool from which it sub-allocates memory from
- : and besides it must pass that allocator the required size, so you can change it if that segment
- : is later used for code, you know the size of the copied code after all and if the size passed to
- : the function is sufficient for the translated code then you don't have to do anything otherwise
- : change it.
-
- As the size of the sub-allocated memory changes You may have to completely
- rewrite the pool-allocator, because it may depend on the allocations being
- of certain sizes or a multiple of a certain sizes etc.
- To do this the translator would have to completely understand the allocator
- and this is impossible.
-
- : > It's not unfounded, but I've thought about some things.
- : > There are much simpler similar problems that are AFAIK proven to be
- : > undecidable.
- :
- : care to elaborate on this please.
-
- I think most standard data flow problems can only be approximated, but exact
- solutions (which would be needed by Your approach) can not be found.
- AFAIR I read somewhere that this was proven for some cases, but unfortunately
- I don't remember where it was.
-
- : what the hell does recursion have to do with anything, it simply calls the function from within
- : itself, so what??? if you follow the changes to a7, then you'll always point to the right address,
- : remember that auto-variables don't exist cuz the programs is not running and so all references are
- : are register (a7) indirect and so nothing really matters, you use registers not absolute addresses.
-
- You seem to think that every program uses variables and registers in the same
- way like a certain compiler. This is not true.
-
- : > What do You mean by ansi-compliant programs and what does this have to do
- : > with it?
- : heheheh, i mean programs that use ansi C conventions for calling functions, register usage etc...
-
- I don't know such ANSI C conventions. Implementation and generated code is
- up to the compiler. There may be OS conventions, but that is something
- completely different.
-
- : > Functions are components of certain high level languages. In machine language
- : > there are only addresses. Even if this code was generated by a compiler You
- : > have to keep track of any jump addresses to be able to determine the
- : > beginning and end of a function and what is code an what is data.
- :
- : gimme one example where i would fail to translate that. believe me it should fine.
-
- I gave several examples. The discussion is rather pointless as long as You
- just say 'I keep track of this' and 'adjust that according to xyz' etc.
- Of course it's possible to rewrite a program to PPC, but You have to show
- that this can be done by an algorithm and this is a different story.
-
- Once You describe Your algorithm I will happily give You an example.
-
- But believe me it will never ever work for anything more than some special
- programs. Data flow analysis can be useful for many things, but there are
- severe limitations and Your approach would practically have to 'understand'
- the program and completely rewrite it.
- This is completely absolutely impossible. No chance. Never. Won't work.
-
- Volker
-
-