LibC.a usage in /usr/lib/boot/chrp.disk.proto

Hi,

I am new to C programming, In my protofile we are adding libC.a entry.
I want to know about the usage of libC.a in ptotofile, we are doing this modification before taking bosboot image.

I tried to take a bosboot image without libC.a entry in protofile. I didn't observed any difference in both the cases.

Can someone should brief me the usage of libC.a in /usr/lib/boot/chrp.disk.proto.

Thanks,

Well, libC.a is a static (compile-time) linkable object library to support system functions written in the matching compiler. It is actually an ar archive of many *.o files compiled from *.cpp, assuming capital C implies C++. Only the referenced code is copied out of the library into your executable, not necessarily the entire file. It can be reworked into a libC.so dynamic, shared object (run-time and read-only parts in shared RAM/VM pages paged direct from the .so, no swap used) library. But really, .o, and hence .a and .so, could come from any mix of compilers and languages, as long as everyone agrees on call stack atructure and such.

I assume this reference is to make sure it is linked into the kernel, which might have to run in a primitive mode that does not support dynamic, shared object library. UNIX systems primarily depend on libc.so, which supports the c language, and is usable in C++ using 'extern "C" {...}' declaration wrappers. The C++ variable names are mangled to code in a check for the type and if a call the argument number and each type. This tells C++ not to mangle c calls and variables. The reciprocal 'extern "C++"{...}' tells the C compiler to mangle to call C++ names.

The answer to your question, more to the point, is that libC.a, or any other file, is not needed unless the file is needed for the system boot.

So, until you add something that is used during the boot phase (e.g., a new device driver) it will not make any difference - because this file system gets mounted over by the disk version of / (root) (phase 2 of AIX boot, aka varyonvg rootvg phase).

To know more about the file layout, and the meaning of the content entries - read the manpage proto

excerpt:

Description

       The proto command creates a prototype file for a file system or part of
       a file system. The mkfs command uses the prototype file as input to
       construct a file system according to a predefined template. The
       prototype file consists of a recursive directory listing of every file
       on the file system, with its owner, group, and protection. It also
       contains the file from which the prototype file is to be initialized,
       formatted as described in the mkfs command.

Hi Michael & DG,

Thanks for your valuable suggestions. Now I got some clear picture about libC.a and protofile.

One small doubt, is it useful to add the libC.a in protofile?
What it will do during system boot up, I mean how can kernel interact with the libC.a during system boot up.

Thanks in advance.

---------- Post updated at 11:56 AM ---------- Previous update was at 11:45 AM ----------

Hi Michael and DG,

Actually I am facing the below error when I have libC.a entry in protofile.

dd: 0511-053 The write failed.
: There is a request to a device or address that does not exist.
67611+1 records in.
1056+1 records out.
Failed to take a bosboot image:

Without libC.a entry there is no problem with bosboot.

Thanks.

Maybe the libC.a file is not where it was told?

Hi,

libC.a file is there in its default location and the soft link also created.

# ls -l /usr/lib/libC.a
lrwxrwxrwx 1 bin bin 23 Feb 28 13:28 /usr/lib/libC.a -> /usr/lpp/xlC/lib/libC.a

Thanks,

Well, we are talking about it being included in, by being statically linked to, the boot kernel, not the final, booted system. It is a static lib, so there is no need for the full file at boot time. Some apps are not symlink friendly.

1 Like