Commit Graph

28 Commits

Author SHA1 Message Date
Lucas De Marchi
a20a37c351 Use static assertions for sizeof checks 2013-04-15 14:14:07 -03:00
Lucas De Marchi
e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi
a4578669ca libkmod-module: mangle the section header, not the section
When we are told to remove the "__versions" section we were mangling
that section instead of tweaking the SHF_ALLOC flag in its header.
2012-11-21 20:23:02 -02:00
Lucas De Marchi
d196b8d99f libkmod-module: Remove key+value vermagic from .modinfo section
When told to force load a module, we were removing only the value of
vermagic instead of the complete entry.

Philippe De Swert (philippe.deswert@jollamobile.com) sent a patch that
was additionally mangling also the last two chars of the key
("vermagic="). Instead of creating an invalid entry in .modinfo section
like this, this patch removes the complete entry, key + value, by
zeroing the entire string.

Much thanks to Philippe who found the issue and pointed to the fix.
2012-11-21 20:22:56 -02:00
Lucas De Marchi
9e2eadb1d7 Silence clang warnings with __unused__ attribute
I hate this kind of READV and WRITEV macros that Gustavo seems to love.
clang-analyzer hates them as well.

I'm not motivated enough to refactor this, but I want a clean clang
report, so just shut it up.
2012-05-23 20:31:18 -03:00
Lucas De Marchi
4321590770 Remove dead increment 2012-04-26 11:42:27 -03:00
Lucas De Marchi
ea17e2b043 elf: privately export kmod_elf_get_section()
This function is used to find a certain section in ELF file. It will be
used to get the modname from an ELF file.
2012-01-26 16:05:05 -02:00
Lucas De Marchi
a66a6a999f Update copyright 2012-01-09 00:41:07 -02:00
Gustavo Sverzut Barbieri
599a032467 elf: zero *array when count is zero. 2012-01-03 14:53:15 -02:00
Gustavo Sverzut Barbieri
674f8590e3 elf: implement kmod_module_get_dependency_symbols()
Uses kmod_elf_get_dependency_symbols() that looks into ".symtab" for
UNDEF symbols and matches the name from ".strtab" to "__versions" to
get crc.

Likely the public API should unify the symbol information getters and
list release, they are almost the same.
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
4b55befd37 elf: add bind type to kmod_modversion.
will be used to share this structure with get_dependency_symbols()
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
45e6db9c01 elf: add get_symbols()
Similar to module-init-tools load_symbols(), it will try .symtab and
.strtab for symbols starting with __crc_, if they are found their crc
is read from ELF's Elf_Sym::st_value.

If not found, then it will fallback to __ksymtab_strings.
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
9bbb72df05 elf: minimum size is enough. 2011-12-24 01:24:55 -02:00
Jan Engelhardt
87beacc99f libkmod: use C99 __func__ over GNU-specific __FUNCTION__ 2011-12-20 13:48:44 -02:00
Luis Felipe Strano Moraes
a969376fb0 Removing warnings when compiling on i686 platform. 2011-12-20 13:15:32 -02:00
Lucas De Marchi
76b8031bce elf: fix regression with empty strings
Commit "b20dc17 Remove unneeded reference to last string" reverted the
fix in "47a0ef6 elf: do not output empty strings." and empty strings are
appearing again in kmod-modinfo.

With this commit we do a bit different and instead of keeping the
reference to last string we skip the '\0' inside the loop.
2011-12-20 12:04:21 -02:00
Lucas De Marchi
51c409b449 Cache the offset of crc
This way we don't need to check every time in loop. Indeed compiler
could already optimize out that checks, but this ways is cleaner and
shorter.
2011-12-20 11:41:19 -02:00
Lucas De Marchi
58b7191c94 Make section size constant since it's always the same 2011-12-20 11:35:17 -02:00
Lucas De Marchi
f8fa525c7f Optimize kmod_elf_get_strings() by reducing calls to memcpy
Copy the entire string only once and then scan it, setting up the
pointers of the vector.
2011-12-20 03:34:28 -02:00
Lucas De Marchi
b20dc17068 Remove unneeded reference to last string 2011-12-20 03:27:51 -02:00
Lucas De Marchi
052656f5b3 Put blank lines where it's due
See CODING-STYLE for reference
2011-12-20 03:27:51 -02:00
Lucas De Marchi
3267026e0b Terminate strv with NULL 2011-12-20 03:27:50 -02:00
Lucas De Marchi
4f0f0e75e2 Reduce ident by continuing early 2011-12-20 03:27:50 -02:00
Gustavo Sverzut Barbieri
1c58590549 elf: skip leading symbol dot in modversion.
Mimics module-init-tools's dump_modversions() that calls skip_dot()
to skip leading dots. This is required for PPC64.
2011-12-19 21:55:27 -02:00
Gustavo Sverzut Barbieri
fc8e58ba4e elf: fix typo that resulted in invalid uint reads for big-endian platforms. 2011-12-19 21:55:22 -02:00
Gustavo Sverzut Barbieri
47a0ef601d elf: do not output empty strings. 2011-12-19 18:32:58 -02:00
Gustavo Sverzut Barbieri
fc27344ed9 elf: fix minimum file size calculation.
there is only a single file header, multiple sections.
2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri
708624a4eb ELF: initial support for modinfo and strip of modversions and vermagic.
Needs testing, but should work.
2011-12-19 15:06:49 -02:00