Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kpatch-build: remove localentry data from ppc64le symtab #973

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

joe-lawrence
Copy link
Contributor

commit f8213c87f64a ("lookup: Fix format string for symtab_read() on
PPC64LE") fixed the symbol table lookup when readelf adds ppc64le
"[<localentry>: 8]" info for functions like so:

  23: 0000000000000008    96 FUNC    LOCAL  DEFAULT [<localentry>: 8]    4 cmdline_proc_show

however, it seems that readelf 2.30-57.el8 displays this in a slightly
different format:

  24493: c000000000587970    96 FUNC    LOCAL  DEFAULT    2 cmdline_proc_show    [<localentry>: 8]

Instead of adding more cases to kpatch-build's lookup.c scanf format,
let's just delete this information from the symtab file with a quick and
dirty sed regex.  This allows us to handle both observed cases (and
perhaps others) while removing the arch-specific scanf formatting in
lookup.c

Fixes: f8213c87f64a ("lookup: Fix format string for symtab_read() on PPC64LE")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>

@joe-lawrence
Copy link
Contributor Author

Hey @kamalesh-babulal ... I stumbled upon this when testing out a simple demo.patch.txt on RHEL-8.1. The error I got was:

/root/kpatch/kpatch-build/create-diff-object: ERROR: cmdline.o: find_local_syms: 175: find_local_syms for cmdline.c: couldn't find in vmlinux symbol table

and I noticed that the localentry data was in a different column:

% grep '\<cmdline_proc_show\>' ~/.kpatch/tmp/vmlinux.symtab 
 24493: c000000000587970    96 FUNC    LOCAL  DEFAULT    2 cmdline_proc_show    [<localentry>: 8]

This PR is very lightly tested, but let me know what you think of the change.

@@ -846,6 +846,9 @@ for i in $FILES; do
fi

readelf -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
if [[ "$ARCH" = "ppc64le" ]]; then
sed -i 's/\[<localentry>: 8\]//' "$SYMTAB"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sed -i 's/\[<localentry>: 8\]//' "$SYMTAB"
sed -ri 's/\s+\[<localentry>: 8\]//' "$SYMTAB"

I think we might want to eat up preceding whitespaces as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the extra whitespace tab... I wasn't sure how to handle both RHEL-8 and @kamalesh-babulal 's originally reported format cases. One uses \t[<localentry>: 8\] and the other (I think) [<localentry>: 8\]\t. Can you think of a regex that handles both cases without concatenating columns?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only handling preceding tab case should be enough since we will never have [<localentry>: 8] at the beginning of the line.

@kamalesh-babulal
Copy link
Contributor

kamalesh-babulal commented Jun 12, 2019

I tried reading the symtab using the readelf shipped with RHEL-8.1 and upstream readelf

# readelf --version
GNU readelf version 2.30-54.el8

# readelf -s --wide ./fs/proc/cmdline.o
...
14: 0000000000000000    96 FUNC    LOCAL  DEFAULT    1 cmdline_proc_show    [<localentry>: 8]

# ./binutils/readelf -v
GNU readelf (GNU Binutils) 2.32.51.20190612

# ./binutils/readelf -s --wide /home/kamalesh/linux/fs/proc/cmdline.o
...
23: 0000000000000008    96 FUNC    LOCAL  DEFAULT [<localentry>: 8]     4 cmdline_proc_show

Looks like some custom patch is breaking the order on RHEL. I liked the idea of the patch.

commit f8213c8 ("lookup: Fix format string for symtab_read() on
PPC64LE") fixed the symbol table lookup when readelf adds ppc64le
"[<localentry>: 8]" info for functions like so:

  23: 0000000000000008    96 FUNC    LOCAL  DEFAULT [<localentry>: 8]    4 cmdline_proc_show

however, it seems that readelf 2.30-57.el8 displays this in a slightly
different format:

  24493: c000000000587970    96 FUNC    LOCAL  DEFAULT    2 cmdline_proc_show    [<localentry>: 8]

Instead of adding more cases to kpatch-build's lookup.c scanf format,
let's just delete this information from the symtab file with a quick and
dirty sed regex.  This allows us to handle both observed cases (and
perhaps others) while removing the arch-specific scanf formatting in
lookup.c

Fixes: f8213c8 ("lookup: Fix format string for symtab_read() on PPC64LE")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
@joe-lawrence
Copy link
Contributor Author

v2
-- Updated with @sm00th's suggestion to remove leading whitespace

Also, @kamalesh-babulal was curious about the origins of the RHEL-specific behavior... as far as I can tell it was included with RHEL8's version of binutils (and will be carried forward) to move the "other" symbol information to the end of the line. The intent was to not break old scripts that expect to see readelf symbol format in particular columns.. ahem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants