File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,20 @@ static int codegen_datasec_def(struct bpf_object *obj,
143
143
var_name , align );
144
144
return - EINVAL ;
145
145
}
146
+ /* Assume 32-bit architectures when generating data section
147
+ * struct memory layout. Given bpftool can't know which target
148
+ * host architecture it's emitting skeleton for, we need to be
149
+ * conservative and assume 32-bit one to ensure enough padding
150
+ * bytes are generated for pointer and long types. This will
151
+ * still work correctly for 64-bit architectures, because in
152
+ * the worst case we'll generate unnecessary padding field,
153
+ * which on 64-bit architectures is not strictly necessary and
154
+ * would be handled by natural 8-byte alignment. But it still
155
+ * will be a correct memory layout, based on recorded offsets
156
+ * in BTF.
157
+ */
158
+ if (align > 4 )
159
+ align = 4 ;
146
160
147
161
align_off = (off + align - 1 ) / align * align ;
148
162
if (align_off != need_off ) {
You can’t perform that action at this time.
0 commit comments