Re: [PATCH v5 04/25] trace-cmd library: Add internal helper function for writing headers before file sections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 6 Dec 2021 17:52:54 +0200
Tzvetomir Stoyanov <tz.stoyanov@xxxxxxxxx> wrote:

> As we discussed, there are two possible approaches for these descriptions:
>  1. To add a new section with these descriptions, that way there will
> be no strings in the section headers. I was thinking more about that
> approach, it will make the parsing much more complicated. As all
> sections are dynamically located in the file, there is no strict order
> - that "description" section can be anywhere, even at the end. That
> way during the parsing these strings will not be available for the
> sections before, and the description cannot be displayed. To solve
> that, parsing should be done in two steps -  first to find that
> "description" section to get all the strings, and second to parse the
> other sections. The description should be part of the section being
> parsed, that's why I decided to go with the second approach.

Again, I would look at the ELF file format for answers ;-)

The "string table" is a special section that is described in the main
header. That way, the first thing it does, is to to look for this table. It
scans all the section headers to find the one that points to the strings,
and then loads that one first.

For string "pointers", the pointer is not an offset into the file, but an
offset into the section (uncompressed). So for reading the file, yes, we
would need to first find the string section, and load all the strings into
memory. Then go back and read the normal sections. Then we have access for
all the strings. I would also say that the string section is optional, and
a file could be created with no strings, as they are for description
purposes only, and in that case, we need to just say "no strings found" for
anything that wants to know the string.

-- Steve

> 2. Have a fixed size description string in the section header, I think
> 32 bytes should be OK.




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux