Nlist equivalent for Linux? - linux

I am just wondering if there is an Linux equivalent to Novels nlist(). nlist()
does the following:
Privileged processes calling nlist() should beware of the possibility of an unexpected file being substituted as the operand.
The nlist() function returns symbol table information for the specified symbol names, for the executable file whose name is supplied as an argument.
Thanks,
Rob

The function that comes closest that I know about is dlinfo. It is completely undocumented in glibc (no man page, nothing in the info files), but is apparently a clone of a Solaris interface, which is documented:
http://docs.oracle.com/cd/E23824_01/html/821-1465/dlinfo-3c.html#scrolltoc
You can find it declared on Linux in dlfcn.h

Related

What is a .clientrc file?

You can find a mention of it here: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
however without any explanation. I couldn't find information about it by googling.
What is the purpose of a .clientrc file?
As mentioned in the comments, ".clientrc" was just chosen as an example file name.
If you google site:code.visualstudio.com clientrc, that page is the only search result. And googling site:github.com/microsoft/vscode "clientrc", all the results are about example code (and most are about that example code specifically).
The .*rc file name pattern is a common convention for application-specific configuration files. There's a baeldung article on it:
Names including rc often signify files or directories of files with code. Specifically, this code consists of commands that are meant to run when a program is executed. Indeed, that program can be an application, but it can also be a whole operating system.
Because of this, the original rc affix and extension both meant “run commands”. In particular, a widely accepted source of the term is the Compatible Time-Sharing System (CTSS)

Find the path to a library when using headless linux image

Hi I'm connected to parallella board , using only UART, I'm written and executing codes using only GNU bash, and I don't have a desktop. only that terminal connection
I'm using DevIL library in a C code, and i receive undefined reference toilInit'` etc..
so I should tell where is the path to DevIL library, what are the GNU bash instructions in order to find the /path/to/DevIL/lib/dir and DevIL lib name, I try find DevIL , and i receive no such file or directory
Try
find / -name libname
where libname is the name of your library. This will return all paths that contain a file with the name libname anywhere in your system. If you have a rough idea of the location, use that path instead of the system root / as this will make the command run faster (When called as above the first argument is telling the find command what directory to search under).
Libraries usually start with libxyz, so perhaps you should check the name as DevIL does not adhere to this convention.
You must know the library name since you will need to pass its name and location as a link option to your C compiler at some point.

Can the existence of a period be used to differentiate between a directory and file?

I want to be able to determine if a path is a file or a directory. All I can get is their names because i'm using dirent.h in c and it does not support entry->d_type for some reason. For cross platform linux / windows, can I just check if the name contains a period or not to see if it's a file or not?
No; filenames can have periods, as can directory names, but neither has to.
For (struct dirent)->d_type to work, it depends on the implementation and support on underlying file system you are using. If this is not supported in the file system it would not work.
Refer to the man
unsigned char d_type
This is the type of the file, possibly unknown. The following constants are defined for its value:
DT_UNKNOWN
The type is unknown. Only some filesystems have full support to return the type of the file, others might always return this value.

Can I get module handle from function address on linux?

Same as Win32:
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)(void*)(myFunc), &h);
http://www.kernel.org/doc/man-pages/online/pages/man3/dlsym.3.html is not helpful.
Use dladdr. Documentation here.
Not per se, no; if the symbol was compiled in instead of accessed via dlopen()/dlsym(), then there is no handle to be returned. (The handle abstraction only exists to enable dlsym() fine control over where it loads symbols from; there is no such control over the original link, except via linker scripts.) In the normal course of events, an object is simply open()ed and mmap()ed, other details being hidden within ld.so and only accessible indirectly via RTLD_DEFAULT and RTLD_NEXT parameters to dlsym(). If you are using dlopen(), you are expected to keep track of your handles.
The only method I am aware of is to parse the contents of /proc/self/maps (and/or perhaps smaps) and then use the symbol address to calculate from the boundaries of the mapped .so (start and its size) within which mapped module the function lies.
Note: /proc/self is a symlink (on Linux) to the current process's (with ID <pid>) meta-information, i.e. /proc/<pid>.
It's possible there is some programming interface to this very information that you could use.
Edit: Ah, so dladdr() would be that interface.

Where is modify_ldt?

I am looking for the modify_ldt function (or constant for syscall) on ubuntu, but I can't find it's declaration anywhere. It's not in sys/types.h (as the man page suggests), nor in linux/ldt.h (doesn't exist) or linux/unistd.h as says here.
Where is it located?
Try using __NR_modify_ldt for the syscall constant. On my system it's defined in asm/unistd_64.h, which is included from unistd.h
As Karl already said, call system call directly. See here

Resources