LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   derefencing NULL pointer with gnu ld (link editor) (https://www.linuxquestions.org/questions/linux-software-2/derefencing-null-pointer-with-gnu-ld-link-editor-149679/)

kishan 02-23-2004 04:46 PM

derefencing NULL pointer with gnu ld (link editor)
 
Hi,

I am porting software from HP-UX to RedHat
Enterprise. While using HP UX, i was able to
successfully dereference NULL pointers by using the
"-Z" option while compiling using aCC/gcc. But this
option does not exist on gnu ld (version: GNU ld
version 2.14.90.0.4 20030523). I am wondering if
there is a similar option that would enable me to
successfully dereference NULL pointers without
crashing the code on Redhat Linux (version: Enterprise
3.1).

Thanks,
Kishan

wapcaplet 02-23-2004 04:49 PM

I didn't even know it was possible to dereference null pointers :) Ordinarily, that'd be an error, I'd think - unless you're actually trying to refer to something in memory at 0x0. What kind of situation would require something like that? (just curious)

kishan 02-23-2004 06:31 PM

Well.. on certain compilers ( & coupled with link editors on that platform), it's possible to run code that could run into dereferencing 0x0 & not crash. A good example would be HP-UX. Frankly, any occurance of this scenario would be due to bad programming.

Since we are porting code from HP-UX to linux, there are a lot of such instances. Instead of going thro the entire source code for a potential crash, i was wondering if there was an easy way out... Just like HP-UX. I'm aware that on Solaris you could link lib0@0.so that fixes this. But i cant seem to find anything for linux.

wapcaplet 02-23-2004 07:49 PM

Interesting... no, I don't know of any way to make it OK to dereference null pointers. Maybe someone else around here has an idea.


All times are GMT -5. The time now is 10:22 AM.