-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cg: correct bitfield offset determination
The C compiler (together with binutils) can represent bitfields using one of two representations: store the actual offset of the bitfield in ctm_offset, or store the base offset of the underlying type in ctm_offset and store the offset within the underlying type as cte_offset. Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
- Loading branch information
Showing
2 changed files
with
139 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
/* | ||
* Verify that DTrace is correctly determining the offset of a bitfield. It | ||
* used to only look at ctm_offset to know the location of the bitfield in the | ||
* parent type, but some compiler/libctf combinations use ctm_offset for the | ||
* offset of the underlying type and depend on cte_offset instead to provide | ||
* the offset within that underlying type. | ||
*/ | ||
#pragma D option quiet | ||
|
||
struct iphdr iph; | ||
|
||
BEGIN | ||
{ | ||
iph.ihl = 5; | ||
iph.version = 4; | ||
|
||
trace(iph.ihl); | ||
trace(iph.version); | ||
|
||
exit(iph.ihl == 5 && iph.version == 4 ? 0 : 1); | ||
} | ||
|
||
ERROR | ||
{ | ||
exit(1); | ||
} |