Linux-Development-Apps Digest #402, Volume #7    Mon, 14 May 01 23:13:14 EDT

Contents:
  Two questions on .so libs ("Doug Smith")
  Re: Timer function ? (Chris)
  Re: find size of available memory? (Chris)
  Re: Two questions on .so libs (John Reiser)
  Re: transpareny
  tutorial ?? ("R@FooN")
  Re: Linux Perl Client -> MSSQL Server 2000;  Can be possible? ("Ray Doerr")
  Re: tutorial ?? (Eric P. McCoy)
  Re: Multithreaded app randomly quits as non-root (Daniel Barron)
  Re: Two questions on .so libs ("Arthur H. Gold")
  compiling for multi processors (Steve Connet)
  Re: key press (Steve Connet)
  Re: key press (Rene Herman)
  Re: Two questions on .so libs ([EMAIL PROTECTED])
  Re: Two questions on .so libs ("Arthur H. Gold")
  Re: key press (Steve Connet)

----------------------------------------------------------------------------

From: "Doug Smith" <[EMAIL PROTECTED]>
Subject: Two questions on .so libs
Date: Mon, 14 May 2001 14:27:30 -0700

Hello.  I had a couple of questions on .so files.

one - can I export functions by an ordinal instead of by name as with win32
dll's?  If so, how?

two - can I choose to not export (hide) functions in a .so?  ie - can I have
internal functions that are not exposed?  If so, how?

Thanks much for your time.



------------------------------

From: Chris <[EMAIL PROTECTED]>
Subject: Re: Timer function ?
Date: Mon, 14 May 2001 21:25:52 +0000

Kaz Kylheku wrote:
> 
> On Mon, 14 May 2001 12:06:21 +0100, Chris <[EMAIL PROTECTED]> wrote:
> >Peet Grobler wrote:
> >>
> >> I need to know if the following function exists in Linux, or if it can
> >> somehow be implemented:
> >>
> >> My program should call a function to set a timer. Arguments include a
> >> sequence number (int), and a function to call if timer expires.
> [ snip ]
> >Or, you could sleep in a thread, which is certainly much
> >less overhead than forking, but pretty ugly. Of course,
> >you then have to get notification back to your main
> >process, presumably via a shared variable with appropriate
> >concurrency control.
> 
> One possibility is, if you are using glibc 2.2, you can use timer_create() to
> make timers which either deliver a signal or invoke a function in the context
> of a new thread. If you use this, then in addition to making the program
> threaded with -pthread, you have to link in -lrt.  These functions are
> described by the Single UNIX Specification (online draft:
> http://www.unix-systems.org/single_unix_specification_v2/)

Ooh! Ugly *and* standardised. The perfect solution ;)

-- 
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
 ``The whole purpose of places like Starbucks is for people with no decision
   making ability to make six decisions just to buy one cup of coffee.''

------------------------------

From: Chris <[EMAIL PROTECTED]>
Subject: Re: find size of available memory?
Date: Mon, 14 May 2001 21:28:08 +0000

Ulrich Lauther wrote:
> 
> Chris <[EMAIL PROTECTED]> wrote:
> : Ulrich Lauther wrote:
> : >
> : > I need to implement an algorithm whose speed depends on the size of
> : > buffers I allocate, so I want to allocate a lot.
> : > On the other hand, I do not want to make the computer swap.
> : > So, how can I find out the size of malloc-able memory without swapping?
> 
> : Parse /proc/meminfo.
> 
> and what number do I go for?
>         total:    used:    free:  shared: buffers:  cached:
>         Mem:  397131776 374337536 22794240 134352896 31215616 220061696
>         Swap: 419479552 17829888 401649664
>         MemTotal:    387824 kB
>         MemFree:      22260 kB
>         MemShared:   131204 kB
>         Buffers:      30484 kB
>         Cached:      214904 kB
>         SwapTotal:   409648 kB
>         SwapFree:    392236 kB
> 
> The "free" memory is very small, as the kernel grabs whatever is available.
> So it's not obvious how much *I* can grab without doing harm.

It's not really possible to answer that question. It might
be possible to, for instance, keep allocating memory until
you find the amount of swap in use rising, but that's (a)
really horrid; (b) not likely to work very well.

-- 
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
 If they existed, they would be here (Fermi)

------------------------------

From: John Reiser <[EMAIL PROTECTED]>
Subject: Re: Two questions on .so libs
Date: Mon, 14 May 2001 14:37:04 -0700

> one - can I export functions by an ordinal instead of by name as with win32
> dll's?  If so, how?

The usual tools do not provide for this.  For something that works on x86,
see http://www.BitWagon.com/elfvector.html .

> two - can I choose to not export (hide) functions in a .so?  ie - can I have
> internal functions that are not exposed?  If so, how?

Use a "version script" at static link time of the shared library; see
http://www.cygnus.com/pubs/gnupro/5_ut/b_Usingld/ldLinker_scripts.html .
Also see the -N, -K, -L, -W flags to objcopy .

-- 
John Reiser, [EMAIL PROTECTED]

------------------------------

From: [EMAIL PROTECTED] ()
Crossposted-To: 
alt.linux,comp.os.linux.development.system,linux.redhat.devel,linux.redhat.development
Subject: Re: transpareny
Date: Mon, 14 May 2001 22:07:59 -0000

In article <dBDL6.3906$[EMAIL PROTECTED]>,
Darren LS <[EMAIL PROTECTED]> wrote:

>how would I incorporate this in my programme? would it be the first part of
>the main function or would I have to stick mymain code in a function?

I suggest looking at the source of a couple of daemons to see
how they do it.  

--
http://www.spinics.net/linux

------------------------------

From: "R@FooN" <[EMAIL PROTECTED]>
Subject: tutorial ??
Date: Tue, 15 May 2001 00:26:41 +0200

is there somewhere on the internet a site about how to learn about
programming X windows aplications 

I know a little C++


thankx ,
R@FooN

------------------------------

From: "Ray Doerr" <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.perl.modules,comp.databases,comp.databases.ms-sqlserver
Subject: Re: Linux Perl Client -> MSSQL Server 2000;  Can be possible?
Date: Mon, 14 May 2001 17:53:50 -0500

I personally haven't used it, but DBI::Proxy was designed for this
specifically.  You would run your Perl script from Linux or Sun which used
DBI::Proxy as well as DBI::ADO.  This would then communicate via TCP/IP to
another script that also implemented DBI::Proxy on a Windows machine that
has the Microsoft SQL Server drivers.




"Jose Gilberto Torres" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Hi to everyone in cyberspace!,
> I don't know the appropriate newgroup to ask this question so please
> don't attack me for it :-)  !!    I have be searching all over the 'net
> to find a way to get a Linux (or Solaris) perl client script to access
> data from a MSSQL Server 2000 server.  So far I found the OpenLink
> driver but on my box it continues to seg fault on me when I try to
> access these drivers.  I was wondering if anyone had successfully able
> to do get perl and mssql to talk to each other.  So far it does not seem
> to be possible.  I hope I am wrong?    Help?  Thanks!!!!!!
>
>
> Jose Torres
>



------------------------------

Subject: Re: tutorial ??
From: [EMAIL PROTECTED] (Eric P. McCoy)
Date: 14 May 2001 18:54:18 -0400

"R@FooN" <[EMAIL PROTECTED]> writes:

> is there somewhere on the internet a site about how to learn about
> programming X windows aplications 

Depends on what sort of tools, if any, you want to use.  Gtk+ and
GNOME both have tutorials, the former far better than the latter,
available at their respect web pages.  I leave the determination of
their exact URLs as an exercise to the reader.

-- 
Eric McCoy <[EMAIL PROTECTED]>
  "Knowing that a lot of people across the world with Geocities sites
absolutely despise me is about the only thing that can add a positive
spin to this situation."  - Something Awful, 1/11/2001

------------------------------

From: Daniel Barron <[EMAIL PROTECTED]>
Subject: Re: Multithreaded app randomly quits as non-root
Date: Mon, 14 May 2001 23:28:14 +0100

In message <[EMAIL PROTECTED]>
[snip]
> > I've tried puting in a signal handler to log signals to syslog, but it never
> > worked.  Nothing got logged.
> 
> Check "pthread_sigmask". This should do what you want.
> 
> D. Stimits, [EMAIL PROTECTED]

Thanks.

-- 
Daniel Barron - use [at jadeb.com] for personal replys.


------------------------------

Date: Mon, 14 May 2001 16:43:39 -0500
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: Two questions on .so libs

Doug Smith wrote:
> 
> Hello.  I had a couple of questions on .so files.
> 
> one - can I export functions by an ordinal instead of by name as with win32
> dll's?  If so, how?
I have no idea what you're talking about.
> 
> two - can I choose to not export (hide) functions in a .so?  ie - can I have
> internal functions that are not exposed?  If so, how?
Yes, by using a version script (in the link step of building the
library). For example, if your shared object has func1, func2 and
func3 but you only want to expose func3 to the outside world, add
`version-script=Versions' to your link line, and create a file
called Versions that looks like

VERSION {
   global:
       func3;
   local:
       func1;
       func2;
};

See the info pages for ld (`info ld') for more details.
> 
> Thanks much for your time.
Sure.

HTH,
--ag

-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account for more
info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
I am looking for work. Contact me.

------------------------------

Subject: compiling for multi processors
From: Steve Connet <[EMAIL PROTECTED]>
Date: Tue, 15 May 2001 00:23:50 GMT

Is there anything special you have to do in your code or
compiling/linking when your app is going to run on a multi-processor
machine as opposed to a single processor machine?

In particular, an app that uses X?

I ask because our X GUI app always dumps out on a BadGC error (with
differing Major opcodes) while running on a multi-processor
machine. But it works like a champ 100% on a single processor machine.

Using gdb and backtracing revealed the last call our app makes is to
XtAppNextEvent(...); when the BadGC occurs on a multi-processor
machine. 

Any ideas?

-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

------------------------------

Subject: Re: key press
From: Steve Connet <[EMAIL PROTECTED]>
Date: Tue, 15 May 2001 00:26:43 GMT

"Neil Butterworth" <[EMAIL PROTECTED]> writes:

> Sorry, could you explain exactly how getchar() addresses the OP's
> requirement?

Must I also killfile you here in this newsgroup as well? You are such
an annoyance. The majority of posts I've seen from you are
condescending. Please, don't reply to my posts. You're a jerk.

-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

------------------------------

From: Rene Herman <[EMAIL PROTECTED]>
Subject: Re: key press
Date: Tue, 15 May 2001 02:31:25 +0200

Steve Connet wrote:

> "Neil Butterworth" <[EMAIL PROTECTED]> writes:
> 
> > Sorry, could you explain exactly how getchar() addresses the OP's
> > requirement?
> 
> Must I also killfile you here in this newsgroup as well? You are such
> an annoyance. The majority of posts I've seen from you are
> condescending. Please, don't reply to my posts. You're a jerk.

Still, he does seem to have somewhat of a point. Getchar would be 
completely useless to the OP.

Rene.


------------------------------

From: [EMAIL PROTECTED]
Subject: Re: Two questions on .so libs
Date: Tue, 15 May 2001 01:19:27 GMT

Arthur H. Gold <[EMAIL PROTECTED]> wrote:
> Doug Smith wrote:
>> 
>> Hello.  I had a couple of questions on .so files.
>> 
>> one - can I export functions by an ordinal instead of by name as with win32
>> dll's?  If so, how?
> I have no idea what you're talking about.

I do.  He means can you export a function by a number ("ordinal") instead 
of by name.  For example in the Win32 world:  if you write a function fn()
into F.DLL... you can have the code for fn() in F.DLL indexed by an ordinal
number, instead of by name... This would result in two files generated: F.DLL
which contains the machine code indexed by ordinal, and F.LIB which maps the
function name "fn" to the ordinal.  Only F.DLL needs to be distributed for 
run-time users of fn(), however F.LIB needs to be present at compile time 
for other objects that want to link to fn().  I suppose a reason for doing 
this is that it hides the function names and entry points in your run time
DLL.... Nowhere in F.DLL does it have the funtion name "fn()" indexed by 
name.

Both Win32 and Linux have the ability to dynamically load shared libs at
run time by name, e.g. the name service switch libs.  Code must be exported
from a library by name for that to work though.

Even though I know what he is referring to, I do have some Q's on how it
is done with .so libs in Linux...

I notice that on my RH system, the /lib/lib*.so files are all not-stripped.
Which would make me believe that at run-time, linkage occurs by name, i.e.
when "ls" is executed, it links to printf() in libc.so by name, as in the 
kernel or dynamic loader looks for some code in libc.so which has an entry
point indexed by a name similar to "printf".

But then I believe on my mini-libs on a boot/rescue floppy, all of the 
/lib/lib*.so files have been stripped to save space, so obviously linkage
must happen some other way.

Therefore, my logic tells me that there must be some kind of ".LIB" 
equivalent in Linux which maps "printf" to an ordinal in the real libc.so,
whether that ordinal is an index number, or an address or whatever. This
could be used at compile time to resolve external references to an ordinal.

But this ordinal must remain unchanged as minor version of the libc.so are
released, or else all will break.

Enough hypothesizing for now, can someone tell me how this really happens
in the Linux ELF world?  Are there some FAQs out there that point out 
how this works?

Thanks,
JT.

------------------------------

Date: Mon, 14 May 2001 20:47:24 -0500
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: Two questions on .so libs

[EMAIL PROTECTED] wrote:
> 
> Arthur H. Gold <[EMAIL PROTECTED]> wrote:
> > Doug Smith wrote:
> >>
> >> Hello.  I had a couple of questions on .so files.
> >>
> >> one - can I export functions by an ordinal instead of by name as with win32
> >> dll's?  If so, how?
> > I have no idea what you're talking about.
> 
> I do.  He means can you export a function by a number ("ordinal") instead
> of by name.  For example in the Win32 world:  if you write a function fn()
> into F.DLL... you can have the code for fn() in F.DLL indexed by an ordinal
> number, instead of by name... This would result in two files generated: F.DLL
> which contains the machine code indexed by ordinal, and F.LIB which maps the
> function name "fn" to the ordinal.  Only F.DLL needs to be distributed for
> run-time users of fn(), however F.LIB needs to be present at compile time
> for other objects that want to link to fn().  I suppose a reason for doing
> this is that it hides the function names and entry points in your run time
> DLL.... Nowhere in F.DLL does it have the funtion name "fn()" indexed by
> name.
Yuck. How bizarrely limiting, not to mention being a maintenance
nightmare. But I'm biased. ;-)
> 
> Both Win32 and Linux have the ability to dynamically load shared libs at
> run time by name, e.g. the name service switch libs.  Code must be exported
> from a library by name for that to work though.
> 
> Even though I know what he is referring to, I do have some Q's on how it
> is done with .so libs in Linux...
> 
> I notice that on my RH system, the /lib/lib*.so files are all not-stripped.
> Which would make me believe that at run-time, linkage occurs by name, i.e.
> when "ls" is executed, it links to printf() in libc.so by name, as in the
> kernel or dynamic loader looks for some code in libc.so which has an entry
> point indexed by a name similar to "printf".
> 
> But then I believe on my mini-libs on a boot/rescue floppy, all of the
> /lib/lib*.so files have been stripped to save space, so obviously linkage
> must happen some other way.
This is not the case. 
Linking is still done by name; it's the nature of the ELF model.
Loading, too, is done by name.
> 
> Therefore, my logic tells me that there must be some kind of ".LIB"
> equivalent in Linux which maps "printf" to an ordinal in the real libc.so,
> whether that ordinal is an index number, or an address or whatever. This
> could be used at compile time to resolve external references to an ordinal.
> 
> But this ordinal must remain unchanged as minor version of the libc.so are
> released, or else all will break.
> 
> Enough hypothesizing for now, can someone tell me how this really happens
> in the Linux ELF world?  Are there some FAQs out there that point out
> how this works?
Well, you're wrong. ;-(

As an example, consider the following:

stellablue:/lib$ file libc-2.1.3.so
libc-2.1.3.so: ELF 32-bit LSB shared object, Intel 80386, version
1, stripped
stellablue:/lib$ nm -n libc-2.1.3.so
nm: libc-2.1.3.so: no symbols
stellablue:/lib$ strings libc-2.1.3.so
_DYNAMIC
_GLOBAL_OFFSET_TABLE_
__libc_global_ctors
__register_frame_info
_fini
__deregister_frame_info
_nl_C_LC_CTYPE
__old_fclose
seed48_r
xdr_cryptkeyres
__dup
longjmp
__libc_tcdrain
stpcpy
putchar
__libc_internal_tsd_set
tsearch
__morecore
...

What happens at load time is that function names are resolved to
addresses through the global offset table.

Unfortunately, I can't give you a specific reference. However, the
most complete references on the whole subject of the ELF format
can be found in Sun's Linker and Libraries Guide (it won't be
Linux specific, but most of the information translates pretty much
directly) -- Sun _did_ originate the format after all -- available
through http://docs.sun.com.

For further information, the very best source is the ld-linux
sources, part of the glibc distribution.

HTH,
--ag

-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account for more
info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
I am looking for work. Contact me.

------------------------------

Subject: Re: key press
From: Steve Connet <[EMAIL PROTECTED]>
Date: Tue, 15 May 2001 02:26:45 GMT

Rene Herman <[EMAIL PROTECTED]> writes:

> Still, he does seem to have somewhat of a point. Getchar would be
> completely useless to the OP.

Ugh, I often forget about the differences between MS os's and *nix
os's when writing some code.

On MS os's a function exists in <conio.h> called kbhit(). You wait
until kbhit() returns true then you getchar(). That's how you do it.

Apparently in *nix os's it isn't that easy. You must use low level
stuff in termios.h.

The following link has code to simulate MS's kbhit() function:

http://www.control.auc.dk/~jnn/c2000/programs/mm5/keyboardhit/msg02541.html


-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.apps newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-Apps Digest
******************************

Reply via email to