Dynamic linking with LD_PRELOAD - get it compiled - Linux
This is a discussion on Dynamic linking with LD_PRELOAD - get it compiled - Linux ; On Tue, 1 Apr 2008 19:27:47 -0700 (PDT) David Schwartz wrote:
| On Apr 1, 9:14 am, phil-news-nos...@ipal.net wrote:
|
|> Code should only be reused within the scope of what it was written for.
|> The idea, then, would ...
-
Re: Dynamic linking with LD_PRELOAD - get it compiled
On Tue, 1 Apr 2008 19:27:47 -0700 (PDT) David Schwartz wrote:
| On Apr 1, 9:14 am, phil-news-nos...@ipal.net wrote:
|
|> Code should only be reused within the scope of what it was written for.
|> The idea, then, would be to write code that has a very wide scope.
|
| Or perhaps it's even possible to write code with a narrow scope but to
| facilitate expansion of the scope. Perhaps we should be thinking about
| extensible code.
That could be another option. Code at least well enough written so that
it is easy to extend it to do more things would be good. Source helps.
I hate re-using code I don't have the source for (e.g. trying to rig the
environment around some binary to get it to achieve something it was not
originally written to do).
I'm also quite comfortable writing things from scratch, depending on the
scale of it. For example, I need a program to replicate a directory tree.
I could use "cp". But I've had some gotchas with the way "cp" behaves,
sometimes. For example, I want the source to replace the target, even if
the source is a file and the target is an existing subtree to replace.
The "cp" program won't do that for me. So I'll end up writing my own.
And I'll end up doing it smaller with little or no library needs so it
will keep the initramfs image smaller. Of course I could start with the
source to "cp" and tweak it. But I have written something like this once
before and it was not hard. I think it would be harder making sure I have
not overlooked something in "cp" (because the code is unfamiliar to me)
than to make sure my own code does exactly what I want.
But that's not for everyone or everything.
--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2008-04-01-2336@ipal.net |
|------------------------------------/-------------------------------------|
-
Re: Dynamic linking with LD_PRELOAD - get it compiled
In message , Johannes Bauer
wrote:
> Dildo Bogumil di Boscopelo schrieb:
>
>> why don't you use the correct parameters?
>
> Because then the code generator needs to know the exact prototype -
> which it doesn't. It doesn't need to look into the data, just pass on
> the pointer. The function handling the data then might include the
> headers and interpret the pointer correctly.
Why not use C++?
For example:
extern "C" int test1(char a, unsigned short b);
template struct decompose;
template
struct decompose< r (*)(p1, p2) > {
typedef r R;
typedef p1 P1;
typedef p2 P2;
};
typedef decompose<__typeof__(&test1)> test1_decomposed;
extern "C" test1_decomposed::R
test1(test1_decomposed::P1 a, test1_decomposed::P2 b) {
}
__typeof__ is not part C++ standard but is provided by GCC, for a more
portable approach use Boost's Typeof library.