<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/scripts/mod/modpost.h, branch v5.11</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.11</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.11'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-12-21T04:57:08Z</updated>
<entry>
<title>modpost: refactor error handling and clarify error/fatal difference</title>
<updated>2020-12-21T04:57:08Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-12-01T10:34:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0fd3fbadd9a85e391828f3ef63ef1e96e2d2d752'/>
<id>urn:sha1:0fd3fbadd9a85e391828f3ef63ef1e96e2d2d752</id>
<content type='text'>
We have 3 log functions. fatal() is special because it lets modpost bail
out immediately. The difference between warn() and error() is the only
prefix parts ("WARNING:" vs "ERROR:").

In my understanding, the expected handling of error() is to propagate
the return code of the function to the exit code of modpost, as
check_exports() etc. already does. This is a good manner in general
because we should display as many error messages as possible in a
single run of modpost.

What is annoying about fatal() is that it kills modpost at the first
error. People would need to run Kbuild again and again until they fix
all errors.

But, unfortunately, people tend to do:
"This case should not be allowed. Let's replace warn() with fatal()."

One of the reasons is probably it is tedious to manually hoist the error
code to the main() function.

This commit refactors error() so any single call for it automatically
makes modpost return the error code.

I also added comments in modpost.h for warn(), error(), and fatal().

Please use fatal() only when you have a strong reason to do so.
For example:

  - Memory shortage (i.e. malloc() etc. has failed)
  - The ELF file is broken, and there is no point to continue parsing
  - Something really odd has happened

For general coding errors, please use error().

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Tested-by: Quentin Perret &lt;qperret@google.com&gt;
</content>
</entry>
<entry>
<title>modpost: rename merror() to error()</title>
<updated>2020-12-21T04:57:08Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-12-01T10:34:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bc72d723ec6b75c53e935e819682c3e67b83e9c1'/>
<id>urn:sha1:bc72d723ec6b75c53e935e819682c3e67b83e9c1</id>
<content type='text'>
The log function names, warn(), merror(), fatal() are inconsistent.

Commit 2a11665945d5 ("kbuild: distinguish between errors and warnings
in modpost") intentionally chose merror() to avoid the conflict with
the library function error(). See man page of error(3).

But, we are already causing the conflict with warn() because it is also
a library function. See man page of warn(3). err() would be a problem
for the same reason.

The common technique to work around name conflicts is to use macros.
For example:

    /* in a header */
    #define error(fmt, ...)  __error(fmt, ##__VA_ARGS__)
    #define warn(fmt, ...)   __warn(fmt, ##__VA_ARGS__)

    /* function definition */
    void __error(const char *fmt, ...)
    {
            &lt;our implementation&gt;
    }

    void __warn(const char *fmt, ...)
    {
            &lt;our implementation&gt;
    }

In this way, we can implement our own warn() and error(), still we can
include &lt;error.h&gt; and &lt;err.h&gt; with no problem.

And, commit 93c95e526a4e ("modpost: rework and consolidate logging
interface") already did that.

Since the log functions are all macros, we can use error() without
causing "conflicting types" errors.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: change elf_info-&gt;size to size_t</title>
<updated>2020-06-06T14:39:20Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3b09efc4f0c94669a928c0453d2dcb54c59543f2'/>
<id>urn:sha1:3b09efc4f0c94669a928c0453d2dcb54c59543f2</id>
<content type='text'>
Align with the mmap / munmap APIs.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: strip .o from modname before calling new_module()</title>
<updated>2020-06-06T14:39:20Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a82f794c41ab51f088af325f5d9acba30a6facdb'/>
<id>urn:sha1:a82f794c41ab51f088af325f5d9acba30a6facdb</id>
<content type='text'>
new_module() conditionally strips the .o because the modname has .o
suffix when it is called from read_symbols(), but no .o when it is
called from read_dump().

It is clearer to strip .o in read_symbols().

I also used flexible-array for mod-&gt;name.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: remove mod-&gt;skip struct member</title>
<updated>2020-06-06T14:39:20Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0b19d54cae11bd5b9e208f52e42d88ad33a3b1d9'/>
<id>urn:sha1:0b19d54cae11bd5b9e208f52e42d88ad33a3b1d9</id>
<content type='text'>
The meaning of 'skip' is obscure since it does not explain
"what to skip".

mod-&gt;skip is set when it is vmlinux or the module info came from
a dump file.

So, mod-&gt;skip is equivalent to (mod-&gt;is_vmlinux || mod-&gt;from_dump).

For the check in write_namespace_deps_files(), mod-&gt;is_vmlinux is
unneeded because the -d option is not passed in the first pass of
modpost.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: add mod-&gt;is_vmlinux struct member</title>
<updated>2020-06-06T14:39:19Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5a438af9db2c4a0b80d51d8c1c9c623b0c0de967'/>
<id>urn:sha1:5a438af9db2c4a0b80d51d8c1c9c623b0c0de967</id>
<content type='text'>
is_vmlinux() is called in several places to check whether the current
module is vmlinux or not.

It is faster and clearer to check mod-&gt;is_vmlinux flag.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: remove mod-&gt;is_dot_o struct member</title>
<updated>2020-06-06T14:38:13Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3379576dd6e708f66498d49b4cec5f9b198791a0'/>
<id>urn:sha1:3379576dd6e708f66498d49b4cec5f9b198791a0</id>
<content type='text'>
Previously, there were two cases where mod-&gt;is_dot_o is unset:

[1] the executable 'vmlinux' in the second pass of modpost
[2] modules loaded by read_dump()

I think [1] was intended usage to distinguish 'vmlinux.o' and 'vmlinux'.
Now that modpost does not parse the executable 'vmlinux', this case
does not happen.

[2] is obscure, maybe a bug. Module.symver stores module paths without
extension. So, none of modules loaded by read_dump() has the .o suffix,
and new_module() unsets -&gt;is_dot_o. Anyway, it is not a big deal because
handle_symbol() is not called for the case.

To sum up, all the parsed ELF files are .o files.

mod-&gt;is_dot_o is unneeded.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: remove get_next_text() and make {grab,release_}file static</title>
<updated>2020-06-06T14:38:13Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=75893572d45399cefbb88443d0878adae9cb0b41'/>
<id>urn:sha1:75893572d45399cefbb88443d0878adae9cb0b41</id>
<content type='text'>
get_next_line() is no longer used. Remove.

grab_file() and release_file() are only used in modpost.c. Make them
static.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: add read_text_file() and get_line() helpers</title>
<updated>2020-06-06T14:38:12Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ac5100f54329676469688d1b5415cd8d6428c909'/>
<id>urn:sha1:ac5100f54329676469688d1b5415cd8d6428c909</id>
<content type='text'>
modpost uses grab_file() to open a file, but it is not suitable for
a text file because the mmap'ed file is not terminated by null byte.
Actually, I see some issues for the use of grab_file().

The new helper, read_text_file() loads the whole file content into a
malloc'ed buffer, and appends a null byte. Then, get_line() reads
each line.

To handle text files, I intend to replace as follows:

  grab_file()    -&gt; read_text_file()
  get_new_line() -&gt; get_line()

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>modpost: drop RCS/CVS $Revision handling in MODULE_VERSION()</title>
<updated>2020-06-06T14:38:12Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-06-01T05:57:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f693153519607449d3e270d9e6af20b032543c05'/>
<id>urn:sha1:f693153519607449d3e270d9e6af20b032543c05</id>
<content type='text'>
As far as I understood, this code gets rid of '$Revision$' or '$Revision:'
of CVS, RCS or whatever in MODULE_VERSION() tags.

Remove the primeval code.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
</feed>
